SQL | Spatial index
A spatial index is a type of extended index that allows you to index a spatial column
A spatial column is a table column that contains data of a spatial data type, such as geometry or geography.
Spatial indexes require that the database table that you are creating the spatial index on also has a clustered primary key index defined.
Why use a spatial index?
In General for testing if two points and/or areas intersect or are within a certain distance.
it allows the query to easily skip over column values that there is no chance of intersection.
When creating the index there are options available that increase the accuracy of the index but with that comes the drawback that the index will use more space.
Create a spatial index
Check Index Usage
The following query should use the spatial index in order to determine the 7 closest points to the specified location