One of my applications (B) uses tempdb to split complex requests into a package. Another application (B) uses complex queries without this.
Appendix A is more efficient for large databases.
But to take a look at your situation, you can execute the DMV script as follows:
-- Get top total worker time queries for entire instance (Query 38) (Top Worker Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], qs.max_worker_time AS [Max Worker Time], qs.execution_count AS [Execution Count], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], qp.query_plan AS [Query Plan], qs.creation_time AS [Creation Time] FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
then you can open the query plan for the query for heavy queries and try to find something like:
StatementOptmEarlyAbortReason = "TimeOut" or StatementOptmEarlyAbortReason = "MemoryLimitExceeded"
These facts tell you to break up a complex request into batch + tempdb
PS. It works with good queries without scanning indexes / tables, missing indexes, etc.
source share