Spatial index is slow when trying to find all the points within a range of a geocode.
2011-12-06 10:50
591 查看
You might need to use an Index hint (i.e. WITH(INDEX( [INDEX_NAME] ))
http://stackoverflow.com/questions/6461496/spatial-index-is-slow-when-trying-to-find-all-the-points-within-a-range-of-a-geo
my example
DECLARE
@search_longitude FLOAT='121.78364585795',
@search_latitude FLOAT='31.2351032520358',
@radius Float=100
DECLARE @search_position geography = geography::Point(@search_latitude, @search_longitude, 4326)
--DECLARE @search_position geography = geography::Point(@search_latitude, @search_longitude, 4326).STBuffer(@radius)
SELECT TOP 50 *
FROM Locations l WITH(INDEX(IX_Stores_Location))
WHERE l.Location is not null and l.Location.STDistance(@search_position) <= @radius
--l.Location.Filter(@search_position)=1
Select top 100 ci.Geocode.STDistance(@g), ci.CIOI from CustomerInformation WITH(INDEX(IX_CI_Geocode)) ci where ci.Geocode.Filter(@region) = 1 order by ci.Geocode.STDistance(@g) asc
http://stackoverflow.com/questions/6461496/spatial-index-is-slow-when-trying-to-find-all-the-points-within-a-range-of-a-geo
my example
DECLARE
@search_longitude FLOAT='121.78364585795',
@search_latitude FLOAT='31.2351032520358',
@radius Float=100
DECLARE @search_position geography = geography::Point(@search_latitude, @search_longitude, 4326)
--DECLARE @search_position geography = geography::Point(@search_latitude, @search_longitude, 4326).STBuffer(@radius)
SELECT TOP 50 *
FROM Locations l WITH(INDEX(IX_Stores_Location))
WHERE l.Location is not null and l.Location.STDistance(@search_position) <= @radius
--l.Location.Filter(@search_position)=1
相关文章推荐
- Layout inflation is the term used within the context of Android to indicate when an XML layout resou
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
- Debug:This kind of launch is configured to openthe debug perspective when it解决办法
- 0x80091007 (The hash value is not correct) error when trying to deploy Windows 7 with SCCM OSD
- You're given a string of lower-case Latin letters. Your task is to find the length of its longest su
- How is jstack being used to find the bottlenect of a java program
- Resolution to the record count increasing of the file exported from DB when ‘0A’ is included in it
- When the RTP port is set to 8005, why is 8006 used by RTP and 8007 for RTCP for all communications ?
- Find the earliest time when a frog can jump to the other side of a river.
- Resolution to the record count increasing of the file exported from DB when ‘0A’ is included in it
- How to fix the problem that the Download rate is too Slow when doing "apt-get install"
- Resolution to the record count increasing of the file exported from DB when ‘0A’ is included in it
- How to release the port of TCP Client immediately when the connection is disconnect with the TCP server. - TCP 客户端与 TCP 服务器断开连接后
- Debug:This kind of launch is configured to openthe debug perspective when it解决办法
- Debug:This kind of launch is configured to openthe debug perspective when it suspends
- Becoming an Xperf Xpert Part 3: The Case of When Auto “wait for it” Logon is Slow
- Java---This kind of launch is configured to open the debug perspective when it suspends
- SQLite: Cannot bind argument at index 1 because the index is out of range. The statement has 0 param
- How to Tell if the I/O of the Database is Slow - 1
- Light is falling on a tree from left side you have to find all the nodes on which this light will fa