Using STCrosses() with a Spatial Index in SQL Server

三世轮回 提交于 2019-12-23 03:22:45

问题


Does The Microsoft StCrosses() function for Geography data support Spatial Index?

When I try to execute this function with Spatial Index I get this error message:

"The query processor could not produce a query plan for a query with a spatial index hint. Reason: Spatial indexes do not support the method name supplied in the predicate. Try removing the index hints or removing SET FORCEPLAN"


回答1:


No.

Indexing spatial data is nontrivial, and the class you are discussing can contain arbitrarily complex figures, not just simple geometric shapes. The specific way shapes and indexing is implemented can make finding overlaps difficult or impossible in the general case. It's also not based on whatever is indexed of the spatial data for complex geometries. This may be why you can't require SQL to only use the index - there is not enough data there. In the degenerate case there may be, but it would not know that, so it is turned off.

Imagine having a star-shape, with complex things embedded in it. The index may only store the boundary of the outer shpe, or the center of the shape, or the bounding rectangle. None of these would be enough to compute the intersect of 2 shapes, or if the shapes actually overlap.

See http://msdn.microsoft.com/en-us/library/bb895265.aspx#geometry to confirm that it is not supported.



来源:https://stackoverflow.com/questions/10911473/using-stcrosses-with-a-spatial-index-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!