2
我有一個數據庫在2 000 000行內與1個地理類型字段包含點。 在另一個數據表中,我有600行,其中包含1個包含多邊形的地理類型字段。Sql Server 2008空間查詢慢
This query to retrieve all the POINT in a POLYGON is very slow
SELECT ID_POINT, ID_POLYGON FROM
(SELECT ID_POINT, COORD FROM POINT_TABLE) as POINT
(SELECT ID_POLYGON, COORD FROM POLYGON_TABLE WHERE ID_POLYGON = 276) as POLYGON
WHERE
(POINT.Coord.STIntersects(POLYGON.COORD) = 1)
我有一個像這樣在每個表1個空間索引:
CREATE SPATIAL INDEX [IDX_POLYGON_COORD] ON [dbo].[POLYGON]
(
[COORD]
)USING GEOGRAPHY_GRID
WITH (
GRIDS =(LEVEL_1 = MEDIUM,LEVEL_2 = MEDIUM,LEVEL_3 = MEDIUM,LEVEL_4 = MEDIUM),
CELLS_PER_OBJECT = 16, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
能不能幫我加快此查詢?
問候