Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-06-01 17:38:49 10月04日 Update

8623 error: The query processor ran out of internal resources and could not produce a query plan

Problem description:

Configure the alarm of SQL Server security 16 to send email notification, as follows:

The following alarm message is received:

View the error log:

Error: 8623, Severity: 16, State: 1.

The query processor ran out of internal resources and could not produce a query plan.

Reason:

This is an emergency that is expected to occur only in extremely complex queries or queries that refer to a very large number of tables or partitions. For example, SELECT records using IN clauses (more than 10000 entries).

Solution:

If it is SQL Server 2008 R2 or earlier, use Server Side Trace; if it is SQL Server 2012 or later, use Extended Event. First, trace to the query that specifically caused the 8623 error. Then optimize the query, you can try to put some of the query results into a temporary table, and then associate them according to conditions.

For the IN clause, let's take a look at the notes section on 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.

"

Other methods:

You can try running a query with a plan wizard that uses prompts option (force order), option (hash join), option (merge join), and option (querytraceon 4102). Convert the behavior to the semi-join processing of SQL Server 2000 by enabling trace flag 4102. Enabling trace flags 4118, 4122 (or 4199 covered) can also avoid the problems you see. Check the documentation to determine the specific reasons for your situation:

Microsoft Knowledge Base article for TF 4122

Microsoft Knowledge Base article for TF 4102, 4118

Microsoft Knowledge Base article for TF 4199

Make the relevant Hotfix patch pack, or upgrade directly to the latest SP package of the corresponding version. Related KB 982376 articles:

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

Use extended events to identify 8623 errors:

Run the following TSQL script in SQL Server 2012 and later:

CREATE EVENT SESSIONoverly_complex_queriesON SERVERADD EVENT sqlserver.error_reported (ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username) WHERE ([severity] = 16AND [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 sessionALTER EVENT SESSION overly_complex_queriesON SERVER STATE = STARTGO

If the creation statement is run in SQL Server 2008 R2, the following error is reported:

Msg 25706, Level 16, State 8, Line 1

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

Reference:

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/

Tags: Query error version trace run event clause reason method flag part problem attempt complexity security information wizard security situation document Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Xiaomi MySQL Huawei Linux