Documente Academic
Documente Profesional
Documente Cultură
5 8 9 12
3.
6 7 10 11
2.
5. Apply
1.
2.
3.
4. Overlay
Identify
Intersecting
actual
grids
a grid
grids
CLR
for
onquery
spatial
method
the
identifies
spatial
object(s)
object
oncandidates
object
candidates
to store to find
in index
matches
/4/2/3/1
/
(“cell 0”)
3 g3 3 0x0000B 42 0
3 0x0000C 42 1
Base Table T 1 0x0000D 42 0
2 0x00014 42 1
Spatial Index S
Optional Sort Remove dup ranges
T(@g)
Ranges
Spatial Index Seek
Fully contained
cells
Partially
contained cells
Optimal value (theoretical) is somewhere
between two extremes
Time needed to
Default values: process false positives
512 - Geometry AUTO grid
768 - Geography AUTO grid
1024 - MANUAL grids
SELECT * FROM table t WITH (SPATIAL_WINDOW_MAX_CELLS=256)
WHERE t.geom.STIntersects(@window)=1;
Give me the closest 5 Italian restaurants
SELECT TOP(5) *
FROM Restaurants r
WHERE r.type = ‘Italian’
AND r.pos.STDistance(@me) IS NOT NULL
ORDER BY r.pos.STDistance(@me)
Find the closest 50 business points to a specific location (out of 22 million in total)
sp_spatial_help_geometry_histogram
sp_spatial_help_geography_histogram
Used for spatial data and index analysis
Arguments
Parameter Type Description
@tabname nvarchar(776) the name of the table for which the index has been specified
Total_Number_Of_Obje Bigint Core Number of cell instances of indexed objects that are tessellated in level 0.
ctCells_In_Level0_In_I For geometry indexes, this will happen if the bounding box of the index is
ndex smaller than the data domain.
A high number of objects in level 0 may require a costly application of
secondary filters if the query window falls partially outside the bounding box.
If the query window falls inside the bounding box, having a high number of
objects in level 0 may actually improve the performance.
Property Type Description
Number_Of_Rows_Selected_By_Primary bigint Core P = Number of rows selected by the primary filter.
_Filter
Number_Of_Rows_Selected_By_Internal bigint Core S = Number of rows selected by the internal filter. For
_Filter these rows, the secondary filter is not called.
Primary_Filter_Efficiency float Core This is O/P as a percentage. The higher the efficiency
is, the less false positives have to be processed by the
secondary filter.
http://sqlblog.com/blo
mrys@microsoft.com gs/michael_rys/
Michael
Rys @SQLServerMike
SQL Server 2012
Eval Copy Hands-On Labs
mva @sqlserver
@TechEd_europe
Get Certified! #msTechEd
http://europe.msteched.com www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
http://europe.msteched.com/sessions