Microsoft KB Archive/309256

= How to troubleshoot SQL Server error 8645 =

Article ID: 309256

Article Last Modified on 12/22/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 2000 64-bit Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2005 Standard Edition
 * Microsoft SQL Server 2005 Developer Edition
 * Microsoft SQL Server 2005 Enterprise Edition
 * Microsoft SQL Server 2005 Express Edition
 * Microsoft SQL Server 2005 Workgroup Edition

-



This article was previously published under Q309256



IN THIS TASK
SUMMARY
 * Symptoms
 * Causes
 * Troubleshooting Steps

REFERENCES



SUMMARY
This step-by-step article describes how to troubleshoot SQL Server error 8645. You may receive the error 8645 when there is a high server workload or when the servers are experiencing high memory pressure.

back to the top

Symptoms
You may see the following 8645 error sporadically:

Error 8645: A time out occurred while waiting for memory resources to execute the query. Re-run the query.

Additionally, you may also see one or more of the following symptoms:  When new users try to connect to SQL Server, they receive a &quot;login failed&quot; error message. Users are disconnected and they receive various error messages. CPU usage is very high on the server.  When you run select * from sysprocesses you see that SPIDs have a waittype of 0x40 or 0x0040 and a last_waittype of RESOURCE_SEMAPHORE.  The System Monitor object SQLServer:Memory Manager displays a non-zero value for Memory Grants Pending. SQL Profiler displays the event &quot;Execution Warnings&quot; that includes the &quot;Wait For Memory&quot; or the &quot;Wait For Memory Timeout&quot; text.</ul>

back to the top

Causes
The error message 8645 is raised when memory-intensive queries, such as those involving sorting and hashing, are queued and are unable to obtain the requested memory before a time-out period. SQL Server waits for memory for a length of time that is based on the query wait configuration value. By default, the query wait value is set to -1, which means SQL Server waits for 25 times the estimated cost of the query. If you modify the query wait value to a non-negative number, SQL Server waits for the number of seconds that you specify in the value of the query wait option.

You may also receive error 8645 under the following circumstances:
 * You have queries that are not properly optimized and therefore consume more resources than necessary.
 * The memory that you allocated to SQL Server is not big enough for the work load that you are running on SQL Server.
 * You do not process all results immediately and therefore memory is held longer than necessary.

back to the top

Troubleshooting Steps
You can use one or more of the following steps to help reduce the chances of receiving error 8645. <ol> Try to optimize performance for any long running queries. To identify long running queries, run a SQL Profiler trace that captures the following counters:

SQL Profiler:

<ul> Errors and Warning: Exception</li> Misc: Execution Plan</li> TSQL: Batch Completed</li></ul>

You can also run the Index Tuning Wizard to identity and to optimize any long running queries.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

311826 INF: Index Tuning Wizard Best Practices

</li> Keep distribution statistics up to date, particularly after large amounts of data modifications.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

195565 INF: How SQL Server 7.0 and SQL Server 2000 Autostats Work

</li> Look for any memory pressure on SQL Server by capturing a System Monitor trace. Capture the following counters to identify any memory pressure on SQL Server.

System Monitor:

<ul> SQLServer:Lock Requests/sec</li> SQLServer:Memory Manager</li> Process:Private bytes</li> Process:Working Set bytes</li></ul>

To relieve memory pressure, allocate more memory to SQL Server by increasing the max server memory configuration option. You can add more physical memory to your computer and you may also want to use the /3GB parameter.

If you are running SQL Server Enterprise Edition, consider using the AWE option to increase the memory that SQL Server can use. In some cases, you may want to increase the number of processors on your computer, which can also increase the virtual memory page file size. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

197379 Configuring page files for optimization and recovery in Windows Server 2003, in Windows 2000, and in Windows NT

197379 Configuring Page Files for Optimization and Recovery

</li> If you are running SQL Server 7.0, test disabling parallelism for SQL Server 7.0 by turning the max degree of parallelism configuration option off. This may affect the performance of some parallel queries, but this also increases query concurrency for SQL Server 7.0 and this helps reduce the possibilities of experiencing error 8645.</li> Make sure that SQL Server clients process all result sets immediately. SQL Server cannot release resources that are dedicated to a query until it receives notification from the client that all result sets have been processed.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

180775 INF: Client Effects on SQL Server Throughput

</li> Check the SQL Server configuration settings for the proper values. Sub-optimal settings for values such as Max Server Memory or Query Wait can increase the chance of this error occurring.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

319942 HOW TO: Determine Proper SQL Server Configuration Settings

</li></ol>

back to the top

<div class="references_section">