在SQL Server中使用空间索引时出错 [英] Error when using Spatial Index in SQL Server

查看:113
本文介绍了在SQL Server中使用空间索引时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用空间索引,当我尝试执行WHERE语句时:

I use Spatial Index and when I try to execute WHERE statement:

WHERE T.GEOMETRY.STIntersects(O.GEOMETRY) = 1 AND T.GEOMETRY.STTouches(O.GEOMETRY) = 0

它工作正常,但是当我尝试使用OR执行时:

It works fine, but when I try to execute with OR:

WHERE T.GEOMETRY.STOverlaps(O.GEOMETRY) = 1 OR T.GEOMETRY.STWithin(O.GEOMETRY) = 1

我收到此错误:

查询处理器无法为包含以下内容的查询生成查询计划 空间索引提示.原因:找不到所需的二进制空间 条件下的方法.尝试删除索引提示或删除SET 强制计划.

The query processor could not produce a query plan for a query with a spatial index hint. Reason: Could not find required binary spatial method in a condition. Try removing the index hints or removing SET FORCEPLAN.

任何帮助,这句话有什么问题?

Any help, what is a problem in this statement?

推荐答案

OR查询问题(通常是性能)的一般解决方案是将它们分开,然后在它们之间使用UNION ALL.通常,这可以在子查询或Common表表达式中完成.

A general solution for issues with OR queries ( typically performance) is to separate them and use UNION ALL between then. This would typically be done in a sub-query, or a Common table expression.

如果您可以发布更多查询,最好发布相关的表模式,那么我可以使用更详细的答案来更新我的答案.

If you could post more of your query, and preferably the relevant table schema, then I can update my answer with a more detailed answer.

这篇关于在SQL Server中使用空间索引时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆