RSS

Internal query processor error:

21 Jul

On SQL Server 2008 SP1, Received a “Internal query processor error: Query processor could not produce a query plan”

Based on http://blogs.msdn.com/b/sqlserverfaq/archive/2014/07/15/troubleshooting-error-8624-severity-16-state-21-internal-query-processor-error-the-query-processor-could-not-produce-a-query-plan.aspx

First of all, please check whether the stats are updated with Full Scan as the optimizer replies on the stats for generating the best execution plan.

We can update them by using the below command for all the statistics created in the associated tables:
UPDATE STATISTICS SchemaName.TableName(StatsName) WITH FULLSCAN;

After updating the stats try to run the query. If it still gives the same error, then the cause of the above error can be:

  1. The SET operators are not correctly set in the instance.
  2. This query is really complex and optimizer timed out while generating the plan.
  3. Maybe we didn’t write the query in optimal way.
  4. Maybe we are missing some indexes or statistics from the database.

If all the SET options are set correctly, so now we know that the optimizer is not able to produce the query plan because of the complexity (join order, where clause, nested tables etc.), so we need to tell the optimizer not to use its own logic and just follow the join order which we specified in the query and produce the query plan (may be a bad plan but just produce it).

We can achieve the above by specifying a clause at the end of the query: OPTION (FORCE ORDER).Now, executed the query and it gave the result. It means that the optimizer produced the query plan (may be a bad plan, but at least it produced that).

 

Leave a comment