SQL Server 查询处理器耗尽内部资源

SQL server query processor ran out of internal resources(SQL Server 查询处理器耗尽内部资源)
本文介绍了SQL Server 查询处理器耗尽内部资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查询:

update mytable 
    set mycol = null
    where id in (
        583048,
        583049,
        ... (50000 more)
)

留言:

查询处理器耗尽了内部资源,无法生成查询计划.这是一个罕见的事件,只预期极其复杂的查询或引用非常大的查询表或分区的数量.请简化查询.如果你认为您错误地收到了此消息,请联系客户支持服务以获取更多信息.

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.

我的查询很简单,我应该如何编写它才能正常工作?

My query is very simple, how should I write it so it works ok?

推荐答案

将值列表插入到 #temp 表中,然后在其上使用 in.

Insert the list of values into a #temp table then use in on that.

如解释在这个答案中,大量的 IN 值会导致它在扩展为 OR

As explained in this answer a large number of IN values can cause it to run out of stack as they get expanded to OR

另见相关连接项

这篇关于SQL Server 查询处理器耗尽内部资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)