I have two tables each with a SHAPE Geom Column, and I'm working on getting the intersected area between every shape in the first table with the second table.
The second table has millions of rows, and hence my query takes a long time to execute. I thought of creating an index on the SHAPE Column using:
create spatial index SPIX_Shape on LAND_V1(Shape) using geometry_auto_grid
I'm getting the following error message:
The CREATE SPATIAL INDEX statement is missing the required parameter 'BOUNDING_BOX'.
Validate the statement against the index-creation syntax.
I'm new to the spatial data world, so correct me if I'm wrong here. Initially, I thought that bounding box should be automatically created by the DB Engine, checking each individual shape Geom and creating a bounding box for that when indexing. How do I manually specify a bounding box for my data?
And will that bounding box then affect the intersected area I calculate at the end? Will it differ depending on the GeomType [Polygon/MultiPolygon/GeometryCollection etc..]?
Here's my query:
select
s1.*,
s2.Shape.STIntersection(s1.Shape) as SHAPE
from LAND_V1 s1
inner join LAND_V2 s2 -- biggerTable
ON s1.Shape.STIntersects(s2.Shape) = 1
How would I leverage spatial indexing here