SQL Server error 1214 ("internal error: there are too many parallel tasks") occurs when a single query spawns more parallel worker threads than the server can handle, often due to excessive parallelism settings or a query that overwhelms the scheduler. The fastest fix is to reduce the query's degree of parallelism (MAXDOP) or lower the cost threshold for parallelism, then test again.
What You'll Need
- Access to SQL Server Management Studio (SSMS) or another query tool with sysadmin or CONTROL SERVER permissions.
- Permission to view and alter server settings (ALTER SERVER STATE, ALTER TRACE, or sysadmin role).
- Knowledge of the database name and the query that triggered the error (if known).
Step-by-Step
- Identify the query causing the error. If the error appears in the SQL Server error log or in an application log, note the session ID (SPID) and the query text. If you don't know the query, skip to step 2 to apply a server-wide fix.
- Check current MAXDOP and cost threshold settings. Run the following query in SSMS:
SELECT * FROM sys.configurations WHERE name IN ('max degree of parallelism', 'cost threshold for parallelism');
Note the current values. MAXDOP is typically 0 (meaning all CPUs), and cost threshold is usually 5. - Reduce MAXDOP to a safer value. A common recommendation is to set MAXDOP to the number of physical cores per NUMA node, but for troubleshooting, set it to 4 or even 2. Use:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'max degree of parallelism', 4; RECONFIGURE;
This limits the number of processors used for parallel plan execution, reducing the chance of too many parallel tasks. - Raise the cost threshold for parallelism. Increase the value so that only expensive queries go parallel. For example, set it to 50:
EXEC sp_configure 'cost threshold for parallelism', 50; RECONFIGURE;
This prevents small queries from spawning parallel workers. - If the error persists, force a single-threaded execution for the problematic query. Add
OPTION (MAXDOP 1)to the query text. For example:SELECT * FROM MyTable OPTION (MAXDOP 1);
This eliminates parallelism for that query entirely. - Restart SQL Server if settings don't take effect immediately. Some configuration changes require a restart, though RECONFIGURE usually applies immediately. If the error continues, restart the SQL Server service (requires downtime).
- Monitor for recurrence. After changes, run the query again. If it succeeds, gradually increase MAXDOP or lower cost threshold to find a balance between performance and stability.
Common Mistakes
- Setting MAXDOP to 0 (all CPUs) on a high-core-count server. This often increases parallel task contention.
- Lowering cost threshold to a very small number (like 1), which causes many queries to go parallel.
- Forgetting to run RECONFIGURE after sp_configure changes.
- Applying MAXDOP 1 to all queries as a permanent fix, which can hurt performance for large queries that benefit from parallelism.
- Not checking the actual query plan to see if the query is already using a high degree of parallelism due to a hint.
Tips
- Use
OPTION (MAXDOP N)per query only for the specific query that fails, not globally. - For OLTP systems, a MAXDOP of 2 or 4 is often sufficient; for reporting or analytics, you can use higher values but test carefully.
- Check the SQL Server error log for the exact session and query when the error occurs—it may include a stack dump that helps identify the query.
- Consider using Resource Governor to limit parallelism for specific workloads if you have multiple applications.
- Keep the cost threshold at or above 20 to avoid trivial queries going parallel.
Troubleshooting
If the error persists after adjusting settings:
- Check for query hints. The query might have
OPTION (MAXDOP 0)or a plan guide forcing high parallelism. Remove or override those hints. - Look for nested parallelism. Some queries (e.g., those using CTEs or subqueries) can spawn multiple parallel branches. Try rewriting the query to simplify it.
- Verify the server's CPU count. Use
SELECT cpu_count FROM sys.dm_os_sys_info;to see how many logical CPUs are available. If it's very high (e.g., 64+), the default MAXDOP of 0 can cause issues. - Check for memory pressure. Parallel queries require memory grants. If the server is low on memory, reduce parallelism further or increase memory if possible.
- Update statistics. Outdated statistics can cause the optimizer to choose a parallel plan inappropriately. Run
UPDATE STATISTICSon the involved tables. - If all else fails, trace the error. Use Extended Events to capture the error and the query text. Create a session with the
error_reportedevent and filter for error number 1214.
Frequently Asked Questions
What does error 1214 mean exactly?
It means SQL Server attempted to create more parallel worker threads than the scheduler can handle, often due to a query with a very high degree of parallelism or a system with limited resources.
Can I fix error 1214 without changing server settings?
Yes, you can add OPTION (MAXDOP 1) to the specific query to force serial execution. This is the quickest fix but may slow down that query.
Will setting MAXDOP to 1 affect other queries?
Only if you set it at the server level or in the query. If you use a query hint, only that query is affected. Server-wide MAXDOP 1 disables parallelism for all queries, which can hurt performance for large data operations.
How do I know the best MAXDOP value for my server?
There's no one-size-fits-all. Start with 4 for most systems, then test your workload. For servers with many cores, you might use the number of cores per NUMA node. Microsoft's guidelines suggest not exceeding 8 for most workloads.
Is this error related to the number of CPUs?
Yes, it's more common on servers with many logical processors (e.g., 32 or more) because SQL Server may try to use too many parallel workers.
Can I prevent this error in the future?
Yes, by setting a reasonable MAXDOP and cost threshold, and by monitoring queries that use high parallelism. Also consider using Resource Governor to cap parallelism for specific applications.