8623错误:The query processor ran out of internal resources and could not pro

本文涉及的产品
云数据库 RDS SQL Server,基础系列 2核4GB
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
简介:

问题描述:


配置了SQL Server安全性16的告警,发送邮件通知,如下:

clip_image001


收到如下告警信息:

clip_image002


查看错误日志:

clip_image003

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

 

原因:


这是一个突发事件,预料中只会发生在极其复杂的查询,或者参照了非常大量的表或者分区的查询。比如,使用IN从句(多于10000个条目)SELECT记录。

 

解决方法:


如果是SQL Server 2008 R2及之前版本,使用Server Side Trace;如果是SQL Server 2012及之后版本,使用Extended Event。首先,跟踪到具体导致8623错误的查询。然后对查询进行优化,可以尝试将部分查询结果放到临时表中,然后再去根据条件关联。


对于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的半连接处理。启用跟踪标志4118、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脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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/











本文转自UltraSQL51CTO博客,原文链接:http://blog.51cto.com/ultrasql/1855439 ,如需转载请自行联系原作者




相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情: https://www.aliyun.com/product/rds/sqlserver
相关文章
|
6月前
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed with multiple
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed with multiple
40 1
|
2月前
|
Go 索引
internal\model\data_support.go:17:10: cannot use _ as value or type
internal\model\data_support.go:17:10: cannot use _ as value or type
|
3月前
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
135 3
|
3月前
|
消息中间件 开发工具
【Azure Service Bus】Service Bus SDK 抛出 ERROR c.a.c.a.i.ActiveClientTokenManager - Error is transient. Rescheduling authorization task at interval 1079000 ms.
【Azure Service Bus】Service Bus SDK 抛出 ERROR c.a.c.a.i.ActiveClientTokenManager - Error is transient. Rescheduling authorization task at interval 1079000 ms.
|
3月前
|
CDN
webpack——The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
webpack——The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
62 0
|
6月前
|
缓存 Java 开发工具
Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. Conflict with dependency ‘com.andr
Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. Conflict with dependency ‘com.andr
33 1
|
11月前
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
|
Java Go
ES 查询时提示:all shards failed [type=search_phase_execution_exception]
ES 查询时提示:all shards failed [type=search_phase_execution_exception]
ES 查询时提示:all shards failed [type=search_phase_execution_exception]
|
Java 数据库连接 mybatis
A query was run and no Result Maps were found for the Mapped Statement
A query was run and no Result Maps were found for the Mapped Statement
223 0
|
存储 Android开发 索引
resource.arsc解析之 Dynamic package reference
加载Theme出错 这是一篇补充文章,在做动态替换resId的过程中,我发现bag类型的ResTable_entry在使用过程中存在问题。比如style,其parent解析一直有问题
288 0