我使用空间索引,当我尝试执行 WHERE
语句时:
WHERE T.GEOMETRY.STIntersects(O.GEOMETRY) = 1 AND T.GEOMETRY.STTouches(O.GEOMETRY) = 0
它工作正常,但是当我尝试使用 OR 执行时:
WHERE T.GEOMETRY.STOverlaps(O.GEOMETRY) = 1 OR T.GEOMETRY.STWithin(O.GEOMETRY) = 1
我收到此错误:
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.
请帮忙,这个语句有什么问题吗?
最佳答案
OR 查询(通常是性能)问题的通用解决方案是将它们分开并在它们之间使用 UNION ALL。这通常在子查询或公共(public)表表达式中完成。
如果您可以发布更多查询,最好是相关的表架构,那么我可以用更详细的答案更新我的答案。
关于sql-server - 在 SQL Server 中使用空间索引时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11088775/