8623錯誤:The query processor ran out of internal resources and could not pro

8623錯誤:The query processor ran out of internal resources and could not produce a query plansql

 

問題描述:express


配置了SQL Server安全性16的告警,發送郵件通知,以下:安全

clip_p_w_picpath001


收到以下告警信息:session

clip_p_w_picpath002


查看錯誤日誌:async

clip_p_w_picpath003

Error: 8623, Severity: 16, State: 1.    
The query processor ran out of internal resources and could not produce a query plan.
ide

 

緣由:sqlserver


這是一個突發事件,預料中只會發生在極其複雜的查詢,或者參照了很是大量的表或者分區的查詢。好比,使用IN從句(多於10000個條目)SELECT記錄。優化

 

解決方法:this


若是是SQL Server 2008 R2及以前版本,使用Server Side Trace;若是是SQL Server 2012及以後版本,使用Extended Event。首先,跟蹤到具體致使8623錯誤的查詢。而後對查詢進行優化,能夠嘗試將部分查詢結果放到臨時表中,而後再去根據條件關聯。spa


對於IN從句,咱們能夠來看看BOL上的附註部分

Explicitly including an extremely large number of values (many thousands of values separated by commas) within the parentheses, in an IN clause can consume resources and return errors 8623 or 8632. To work around this problem, store the items in the IN list in a table, and use a SELECT subquery within an IN clause.

Error 8623:

The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.

Error 8632:

Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.


其餘方法:


能夠嘗試運行帶有使用了提示option(force order)、option(hash join)、option(merge join)、option(querytraceon 4102)的計劃嚮導的查詢。經過啓用跟蹤標誌4102,將行爲轉爲SQL Server 2000的半鏈接處理。啓用跟蹤標誌411八、4122(或者涵蓋的4199)也能夠避免你看到的問題。查看文檔肯定你的狀況下的具體緣由:

Microsoft Knowledge Base article for TF 4122

Microsoft Knowledge Base article for TF 4102, 4118

Microsoft Knowledge Base article for TF 4199


打相關Hotfix補丁包,或者直接升級到對應版本最新的SP包。相關KB 982376文章:

FIX: A non-yielding scheduler error or an error 8623 occurs when you run a query that contains a large IN clause in SQL Server 2005, SQL Server 2008, or SQL Server 2008 R2

 

使用擴展事件識別8623錯誤:

 

在SQL Server 2012及後續版本運行如下TSQL腳本:

CREATE EVENT SESSION
overly_complex_queries
ON SERVER
ADD EVENT sqlserver.error_reported
(
ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username)
WHERE ([severity] = 16
AND [error_number] = 8623)
)
ADD TARGET package0.asynchronous_file_target
(set filename = 'E:\SQL-DATA\XE\overly_complex_queries.xel' ,
metadatafile = 'E:\SQL-DATA\XE\overly_complex_queries.xem',
max_file_size = 10,
max_rollover_files = 5)
WITH (MAX_DISPATCH_LATENCY = 5SECONDS)
GO
-- Start the session
ALTER EVENT SESSION overly_complex_queries
ON SERVER STATE = START
GO


該建立語句若在SQL Server 2008 R2中運行,會報以下錯誤:

Msg 25706, Level 16, State 8, Line 1

The event attribute or predicate source, "error_number", could not be found.

 

參考:

https://blogs.technet.microsoft.com/mdegre/2012/03/13/8623-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan/

http://dba.stackexchange.com/questions/28945/query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan

https://mssqlwiki.com/2012/10/07/optimizer-timeout-or-optimizer-memory-abort/

http://blog.rdx.com/blog/dba_tips/2014/05/using-server-trace-to-identify-8623-errors

http://jasonbrimhall.info/2014/01/02/day-9-queries-going-boom/

相關文章
相關標籤/搜索