SlideShare a Scribd company logo
: How do I tell?
A: SELECT * FROM T   WHERE g.STIntersects(@x) = 1
SELECT *
FROM T WITH(INDEX(T_g_idx))
WHERE g.STIntersects(@x) = 1
Plan choice is cost-based
   QO uses various information, including cardinality
   EXEC sp_executesql
   SELECT
   DECLARE*@x geometry = 'POINT (0 0)'
   SELECT N'SELECT *
   FROM T *
   WHERE FROM T
   FROM TT.g.STIntersects('POINT (0 0)') = 1
            WHERE T.g.STIntersects(@x) = 1',
   WHERE T.g.STIntersects(@x) = 1
            N'@x geometry', N'POINT (0 0)'

When can we estimate cardinality?
  Variables: never
  Literals: not for spatial since they are not literals under the covers
  Parameters: yes, but cached, so first call matters
C
        B                                D A      B                        A    B
D A
                    Primary Filter                       Secondary Filter
         E          (Index lookup)                       (Original predicate)

In general, split predicates in two
      Primary filter finds all candidates, possibly
      with false positives (but never false negatives)
      Secondary filter removes false positives
The index provides our primary filter
Original predicate is our secondary filter
Some tweaks to this scheme
      Sometimes possible to skip secondary filter
Secondary Filter
        IndexingFilter
        Primary Phase
   1        2       15      16
                                       1.
   4        3       14      13


   5        8       9       12
                                            3.
   6        7       10      11
                                       2.

5.
4. Apply actual on the spatial
3. Intersecting grids method
2. Identify a gridfor query on
1. Overlay gridsCLR spatialobject(s)
                       identifies
candidates to find matches
object to store in index
/4/2/3/1
    /
(“cell 0”)




 Deepest-cell Optimization: Only keep the lowest level cell in index
 Covering Optimization: Only record higher level cells when all lower
 cells are completely covered by the object
 Cell-per-object Optimization: User restricts max number of cells per object
0 – cell at least touches the object (but not 1 or 2)
                                            Spatial Reference ID
                              1 – guarantee thatto be encoding
                                        Varbinary(5) the same to produce
                                            Have object partially covers cell
               15 columns and 2 – object covers cell id
                              895 byte limitation
                                        of grid cell
                                            match

    Prim_key       geography                             Prim_key     cell_id         srid   cell_attr
                                                         1            0x00007         42     0
    1              g1
                                                         3            0x00007         42     1
    2              g2                                    3            0x0000A         42     2
    3              g3                                    3            0x0000B         42     0
                                                         3            0x0000C         42     1
        Base Table T                                     1            0x0000D         42     0
                                                         2            0x00014         42     1

CREATE SPATIAL INDEX sixd                                    Internal Table for sixd
ON T(geography)
Create index example GEOMETRY:
         CREATE SPATIAL INDEX sixd ON spatial_table(geom_column)
         WITH (BOUNDING_BOX = (0, 0, 500, 500),
                GRIDS = (LOW, LOW, MEDIUM, HIGH),
                CELLS_PER_OBJECT = 20)

     Create index example GEOGRAPHY:
         CREATE SPATIAL INDEX sixd ON spatial_table(geogr_column)
         USING GEOGRAPHY_GRID
         WITH (GRIDS = (LOW, LOW, MEDIUM, HIGH),
                CELLS_PER_OBJECT = 20)

     NEW IN SQL Server 2012 (equivalent to default creation):
         CREATE SPATIAL INDEX sixd ON spatial_table(geom_column)
         USING GEOGRAPHY_AUTO_GRID
         WITH (CELLS_PER_OBJECT = 20)

14   Use ALTER and DROP INDEX for maintenance.
Geometry:
   STIntersects() = 1    •
                         •
   STOverlaps() = 1
                         •
   STEquals()= 1         •
   STTouches() = 1       •
                         •
   STWithin() = 1
                         •
   STContains() = 1      •
   STDistance() < val    •
   STDistance() <= val
   Nearest Neighbor
   Filter() = 1
Itself
 Ancestors
 Descendants
                  7   7.2   7.2.4


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




       Default values:                                    Time needed to
512 - Geometry AUTO grid                               process false positives
768 - Geography AUTO grid
1024 - SELECT * FROM table t WITH
        MANUAL grids             (SPATIAL_WINDOW_MAX_CELLS=256)
      WHERE t.geom.STIntersects(@window)=1;
Give me the closest 5 Italian restaurants

      SQL Server 2008/2008 R2: table scan
      SQL Server 2012: uses spatial index


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

@indexname          sysname         the index name to be investigated
@verboseoutput      tinyint         0 core set of properties is reported
                                    1 all properties are being reported
@query_sample       geometry        A representative query sample that will be used to test the
                                    usefulness of the index. It may be a representative object or a
                                    query window.




PropName: nvarchar(256)               PropValue: sql_variant
Parameter        Type            Description
@tabname         nvarchar(776)   the name of the table for which the index has been
                                 specified
@indexname       sysname         the index name to be investigated
@verboseoutput   tinyint         0 core set of properties is reported
                                 1 all properties are being reported
@query_sample    geography       A representative query sample that will be used to
                                 test the usefulness of the index. It may be a
                                 representative object or a query window.

@xml_output      xml             This is an output parameter that contains the
                                 returned properties in an XML fragment
Property                 Type            Description
Base_Table_Rows          Bigint   All    Number of rows in the base table
Index properties         -        All    index properties: bounding box, grid densities, cell per object
Total_Primary_Index_R    Bigint   All    Number of rows in the index
ows
Total_Primary_Index_P    Bigint   All    Number of pages in the index
ages
Total_Number_Of_Obje     Bigint   Core   Indicates whether the representative query sample falls outside of the
ctCells_In_Level0_For_                   bounding box of the geometry index and into the root cell (level 0 cell). This is
QuerySample                              either 0 (not in level 0 cell) or 1. If it is in the level 0 cell, then the
                                         investigated index is not an appropriate index for the query sample.

Total_Number_Of_Obje     Bigint   Core   Number of cell instances of indexed objects that are tessellated in level 0. For
ctCells_In_Level0_In_I                   geometry indexes, this will happen if the bounding box of the index is smaller
ndex                                     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.

Number_Of_Times_Secondary_Filter_Is_     bigint   Core   Number of times the secondary filter is called.
Called
Percentage_Of_Rows_NotSelected_By_Pri    float    Core   Suppose there are N rows in the base table, suppose P
mary_Filter                                              are selected by the primary filter. This is (N-P)/N as
                                                         percentage.
Percentage_Of_Primary_Filter_Rows_Sele   float    Core   This is S/P as a percentage. The higher the percentage,
cted_By_Internal_Filter                                  the better is the index in avoiding the more expensive
                                                         secondary filter.

Number_Of_Rows_Output                    bigint   Core   O=Number of rows output by the query.
Internal_Filter_Efficiency               float    Core   This is S/O as a percentage.
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://social.technet.microsoft.com/wiki/contents/articles/updated-spatial-features-in-the-sql-
   azure-q4-2011-service-release.aspx




Forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1629&SiteID=1

More Related Content

What's hot

OpenXR 0.90 Overview Guide
OpenXR 0.90 Overview GuideOpenXR 0.90 Overview Guide
OpenXR 0.90 Overview Guide
The Khronos Group Inc.
 
Chapter2
Chapter2Chapter2
Chapter2
Krishna Kumar
 
Array
ArrayArray
Array
Anil Dutt
 
Database security
Database securityDatabase security
Database security
Rambabu Duddukuri
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
bhavesh prakash
 
Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
chanchal ghosh
 
Optimizing array-based data structures to the limit
Optimizing array-based data structures to the limitOptimizing array-based data structures to the limit
Optimizing array-based data structures to the limit
Roman Leventov
 
Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentationNeveen Reda
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
Josh Doyle
 
Collection v3
Collection v3Collection v3
Collection v3
Sunil OS
 
Arrays in java language
Arrays in java languageArrays in java language
Arrays in java language
Hareem Naz
 

What's hot (20)

Hack reduce mr-intro
Hack reduce mr-introHack reduce mr-intro
Hack reduce mr-intro
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
OpenXR 0.90 Overview Guide
OpenXR 0.90 Overview GuideOpenXR 0.90 Overview Guide
OpenXR 0.90 Overview Guide
 
Chapter2
Chapter2Chapter2
Chapter2
 
Array
ArrayArray
Array
 
Database security
Database securityDatabase security
Database security
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Array lecture
Array lectureArray lecture
Array lecture
 
Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
 
Chapter2
Chapter2Chapter2
Chapter2
 
Optimizing array-based data structures to the limit
Optimizing array-based data structures to the limitOptimizing array-based data structures to the limit
Optimizing array-based data structures to the limit
 
Array
ArrayArray
Array
 
Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentation
 
MA3696 Lecture 6
MA3696 Lecture 6MA3696 Lecture 6
MA3696 Lecture 6
 
Clojure class
Clojure classClojure class
Clojure class
 
Plc (1)
Plc (1)Plc (1)
Plc (1)
 
Plc (1)
Plc (1)Plc (1)
Plc (1)
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
Collection v3
Collection v3Collection v3
Collection v3
 
Arrays in java language
Arrays in java languageArrays in java language
Arrays in java language
 

Viewers also liked

Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Mihail Mateev
 
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQLThe DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
torp42
 
Spatial Indexing
Spatial IndexingSpatial Indexing
Spatial Indexing
torp42
 
VO Course 11: Spatial indexing
VO Course 11: Spatial indexingVO Course 11: Spatial indexing
VO Course 11: Spatial indexing
Joint ALMA Observatory
 
SQLBits X SQL Server 2012 Spatial
SQLBits X SQL Server 2012 SpatialSQLBits X SQL Server 2012 Spatial
SQLBits X SQL Server 2012 Spatial
Michael Rys
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Texas Natural Resources Information System
 
Geek Sync | Having Fun with Spatial Data
Geek Sync | Having Fun with Spatial DataGeek Sync | Having Fun with Spatial Data
Geek Sync | Having Fun with Spatial Data
IDERA Software
 
Enabling Access to Big Geospatial Data with LocationTech and Apache projects
Enabling Access to Big Geospatial Data with LocationTech and Apache projectsEnabling Access to Big Geospatial Data with LocationTech and Apache projects
Enabling Access to Big Geospatial Data with LocationTech and Apache projects
Rob Emanuele
 
Spatial Data processing with Hadoop
Spatial Data processing with HadoopSpatial Data processing with Hadoop
Spatial Data processing with Hadoop
VisionGEOMATIQUE2014
 
SQL - מודל הנתונים
SQL - מודל הנתוניםSQL - מודל הנתונים
SQL - מודל הנתונים
מורן אלקובי
 
RTree Spatial Indexing with MongoDB - MongoDC
RTree Spatial Indexing with MongoDB - MongoDC RTree Spatial Indexing with MongoDB - MongoDC
RTree Spatial Indexing with MongoDB - MongoDC
Nicholas Knize, Ph.D., GISP
 
Thesis powerpoint
Thesis powerpointThesis powerpoint
Thesis powerpoint
MalissaHopeCollins
 
Geo tagging & spatial indexing of text-specified data
Geo tagging & spatial indexing of text-specified dataGeo tagging & spatial indexing of text-specified data
Geo tagging & spatial indexing of text-specified data
Shiv Shakti Ghosh
 
Thesis Powerpoint
Thesis PowerpointThesis Powerpoint
Thesis Powerpointneha47
 
Thesis Power Point Presentation
Thesis Power Point PresentationThesis Power Point Presentation
Thesis Power Point Presentationriddhikapandya1985
 

Viewers also liked (16)

Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
 
Optimizing spatial database
Optimizing spatial databaseOptimizing spatial database
Optimizing spatial database
 
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQLThe DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
 
Spatial Indexing
Spatial IndexingSpatial Indexing
Spatial Indexing
 
VO Course 11: Spatial indexing
VO Course 11: Spatial indexingVO Course 11: Spatial indexing
VO Course 11: Spatial indexing
 
SQLBits X SQL Server 2012 Spatial
SQLBits X SQL Server 2012 SpatialSQLBits X SQL Server 2012 Spatial
SQLBits X SQL Server 2012 Spatial
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...
 
Geek Sync | Having Fun with Spatial Data
Geek Sync | Having Fun with Spatial DataGeek Sync | Having Fun with Spatial Data
Geek Sync | Having Fun with Spatial Data
 
Enabling Access to Big Geospatial Data with LocationTech and Apache projects
Enabling Access to Big Geospatial Data with LocationTech and Apache projectsEnabling Access to Big Geospatial Data with LocationTech and Apache projects
Enabling Access to Big Geospatial Data with LocationTech and Apache projects
 
Spatial Data processing with Hadoop
Spatial Data processing with HadoopSpatial Data processing with Hadoop
Spatial Data processing with Hadoop
 
SQL - מודל הנתונים
SQL - מודל הנתוניםSQL - מודל הנתונים
SQL - מודל הנתונים
 
RTree Spatial Indexing with MongoDB - MongoDC
RTree Spatial Indexing with MongoDB - MongoDC RTree Spatial Indexing with MongoDB - MongoDC
RTree Spatial Indexing with MongoDB - MongoDC
 
Thesis powerpoint
Thesis powerpointThesis powerpoint
Thesis powerpoint
 
Geo tagging & spatial indexing of text-specified data
Geo tagging & spatial indexing of text-specified dataGeo tagging & spatial indexing of text-specified data
Geo tagging & spatial indexing of text-specified data
 
Thesis Powerpoint
Thesis PowerpointThesis Powerpoint
Thesis Powerpoint
 
Thesis Power Point Presentation
Thesis Power Point PresentationThesis Power Point Presentation
Thesis Power Point Presentation
 

Similar to SQLBits X SQL Server 2012 Spatial Indexing

SQLPASS AD404-M Spatial Index MRys
SQLPASS AD404-M Spatial Index MRysSQLPASS AD404-M Spatial Index MRys
SQLPASS AD404-M Spatial Index MRys
Michael Rys
 
Core java by a introduction sandesh sharma
Core java by a introduction sandesh sharmaCore java by a introduction sandesh sharma
Core java by a introduction sandesh sharma
Sandesh Sharma
 
The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202
Mahmoud Samir Fayed
 
Sdtl manual
Sdtl manualSdtl manual
Sdtl manual
qaz8989
 
Enter The Matrix
Enter The MatrixEnter The Matrix
Enter The Matrix
Mike Anderson
 
Learn How to Master Solr1 4
Learn How to Master Solr1 4Learn How to Master Solr1 4
Learn How to Master Solr1 4
Lucidworks (Archived)
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
MongoDB
 
Arrays
ArraysArrays
Integrity constraint fundamentals of dbms.pdf
Integrity constraint fundamentals of dbms.pdfIntegrity constraint fundamentals of dbms.pdf
Integrity constraint fundamentals of dbms.pdf
Saikrishna492522
 
Cpcs 203 -array-problems
Cpcs 203 -array-problemsCpcs 203 -array-problems
Cpcs 203 -array-problems
MaherAalQasim
 
Principal Component Analysis For Novelty Detection
Principal Component Analysis For Novelty DetectionPrincipal Component Analysis For Novelty Detection
Principal Component Analysis For Novelty Detection
Jordan McBain
 
Implementing IDR in __alloc_fd()
Implementing IDR in __alloc_fd()Implementing IDR in __alloc_fd()
Implementing IDR in __alloc_fd()
Sandhya Bankar
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
Mike Anderson
 
MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...
MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...
MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...
The Statistical and Applied Mathematical Sciences Institute
 
Efficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLEfficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCL
Jonas Traub
 

Similar to SQLBits X SQL Server 2012 Spatial Indexing (20)

SQLPASS AD404-M Spatial Index MRys
SQLPASS AD404-M Spatial Index MRysSQLPASS AD404-M Spatial Index MRys
SQLPASS AD404-M Spatial Index MRys
 
Core java by a introduction sandesh sharma
Core java by a introduction sandesh sharmaCore java by a introduction sandesh sharma
Core java by a introduction sandesh sharma
 
Java unit i
Java unit iJava unit i
Java unit i
 
The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196
 
The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202
 
Sdtl manual
Sdtl manualSdtl manual
Sdtl manual
 
Enter The Matrix
Enter The MatrixEnter The Matrix
Enter The Matrix
 
Learn How to Master Solr1 4
Learn How to Master Solr1 4Learn How to Master Solr1 4
Learn How to Master Solr1 4
 
TeraSort
TeraSortTeraSort
TeraSort
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
 
Arrays
ArraysArrays
Arrays
 
Integrity constraint fundamentals of dbms.pdf
Integrity constraint fundamentals of dbms.pdfIntegrity constraint fundamentals of dbms.pdf
Integrity constraint fundamentals of dbms.pdf
 
ICSM07.ppt
ICSM07.pptICSM07.ppt
ICSM07.ppt
 
Cpcs 203 -array-problems
Cpcs 203 -array-problemsCpcs 203 -array-problems
Cpcs 203 -array-problems
 
Principal Component Analysis For Novelty Detection
Principal Component Analysis For Novelty DetectionPrincipal Component Analysis For Novelty Detection
Principal Component Analysis For Novelty Detection
 
Implementing IDR in __alloc_fd()
Implementing IDR in __alloc_fd()Implementing IDR in __alloc_fd()
Implementing IDR in __alloc_fd()
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...
MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...
MUMS Undergraduate Workshop - Parameter Selection and Model Calibration for a...
 
Efficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLEfficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCL
 

More from Michael Rys

Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Michael Rys
 
Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)
Michael Rys
 
Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...
Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...
Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...
Michael Rys
 
Running cost effective big data workloads with Azure Synapse and Azure Data L...
Running cost effective big data workloads with Azure Synapse and Azure Data L...Running cost effective big data workloads with Azure Synapse and Azure Data L...
Running cost effective big data workloads with Azure Synapse and Azure Data L...
Michael Rys
 
Big Data Processing with Spark and .NET - Microsoft Ignite 2019
Big Data Processing with Spark and .NET - Microsoft Ignite 2019Big Data Processing with Spark and .NET - Microsoft Ignite 2019
Big Data Processing with Spark and .NET - Microsoft Ignite 2019
Michael Rys
 
Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...
Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...
Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...
Michael Rys
 
Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...
Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...
Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...
Michael Rys
 
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Michael Rys
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Michael Rys
 
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Michael Rys
 
Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...
Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...
Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...
Michael Rys
 
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
Michael Rys
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Michael Rys
 
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
Michael Rys
 
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
Michael Rys
 
Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)
Michael Rys
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Michael Rys
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Michael Rys
 
Killer Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQLKiller Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQL
Michael Rys
 
ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)
Michael Rys
 

More from Michael Rys (20)

Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
Big Data and Data Warehousing Together with Azure Synapse Analytics (SQLBits ...
 
Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)Big Data Processing with .NET and Spark (SQLBits 2020)
Big Data Processing with .NET and Spark (SQLBits 2020)
 
Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...
Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...
Running cost effective big data workloads with Azure Synapse and ADLS (MS Ign...
 
Running cost effective big data workloads with Azure Synapse and Azure Data L...
Running cost effective big data workloads with Azure Synapse and Azure Data L...Running cost effective big data workloads with Azure Synapse and Azure Data L...
Running cost effective big data workloads with Azure Synapse and Azure Data L...
 
Big Data Processing with Spark and .NET - Microsoft Ignite 2019
Big Data Processing with Spark and .NET - Microsoft Ignite 2019Big Data Processing with Spark and .NET - Microsoft Ignite 2019
Big Data Processing with Spark and .NET - Microsoft Ignite 2019
 
Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...
Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...
Bringing the Power and Familiarity of .NET, C# and F# to Big Data Processing ...
 
Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...
Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...
Building data pipelines for modern data warehouse with Apache® Spark™ and .NE...
 
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
Modernizing ETL with Azure Data Lake: Hyperscale, multi-format, multi-platfor...
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
 
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
 
Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...
Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...
Best practices on Building a Big Data Analytics Solution (SQLBits 2018 Traini...
 
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
U-SQL Killer Scenarios: Custom Processing, Big Cognition, Image and JSON Proc...
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
 
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
 
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
 
Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
 
Killer Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQLKiller Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQL
 
ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 

SQLBits X SQL Server 2012 Spatial Indexing

  • 1.
  • 2. : How do I tell? A: SELECT * FROM T WHERE g.STIntersects(@x) = 1
  • 3. SELECT * FROM T WITH(INDEX(T_g_idx)) WHERE g.STIntersects(@x) = 1
  • 4. Plan choice is cost-based QO uses various information, including cardinality EXEC sp_executesql SELECT DECLARE*@x geometry = 'POINT (0 0)' SELECT N'SELECT * FROM T * WHERE FROM T FROM TT.g.STIntersects('POINT (0 0)') = 1 WHERE T.g.STIntersects(@x) = 1', WHERE T.g.STIntersects(@x) = 1 N'@x geometry', N'POINT (0 0)' When can we estimate cardinality? Variables: never Literals: not for spatial since they are not literals under the covers Parameters: yes, but cached, so first call matters
  • 5. C B D A B A B D A Primary Filter Secondary Filter E (Index lookup) (Original predicate) In general, split predicates in two Primary filter finds all candidates, possibly with false positives (but never false negatives) Secondary filter removes false positives The index provides our primary filter Original predicate is our secondary filter Some tweaks to this scheme Sometimes possible to skip secondary filter
  • 6.
  • 7.
  • 8. Secondary Filter IndexingFilter Primary Phase 1 2 15 16 1. 4 3 14 13 5 8 9 12 3. 6 7 10 11 2. 5. 4. Apply actual on the spatial 3. Intersecting grids method 2. Identify a gridfor query on 1. Overlay gridsCLR spatialobject(s) identifies candidates to find matches object to store in index
  • 9.
  • 10. /4/2/3/1 / (“cell 0”) Deepest-cell Optimization: Only keep the lowest level cell in index Covering Optimization: Only record higher level cells when all lower cells are completely covered by the object Cell-per-object Optimization: User restricts max number of cells per object
  • 11. 0 – cell at least touches the object (but not 1 or 2) Spatial Reference ID 1 – guarantee thatto be encoding Varbinary(5) the same to produce Have object partially covers cell 15 columns and 2 – object covers cell id 895 byte limitation of grid cell match Prim_key geography Prim_key cell_id srid cell_attr 1 0x00007 42 0 1 g1 3 0x00007 42 1 2 g2 3 0x0000A 42 2 3 g3 3 0x0000B 42 0 3 0x0000C 42 1 Base Table T 1 0x0000D 42 0 2 0x00014 42 1 CREATE SPATIAL INDEX sixd Internal Table for sixd ON T(geography)
  • 12.
  • 13.
  • 14. Create index example GEOMETRY: CREATE SPATIAL INDEX sixd ON spatial_table(geom_column) WITH (BOUNDING_BOX = (0, 0, 500, 500), GRIDS = (LOW, LOW, MEDIUM, HIGH), CELLS_PER_OBJECT = 20) Create index example GEOGRAPHY: CREATE SPATIAL INDEX sixd ON spatial_table(geogr_column) USING GEOGRAPHY_GRID WITH (GRIDS = (LOW, LOW, MEDIUM, HIGH), CELLS_PER_OBJECT = 20) NEW IN SQL Server 2012 (equivalent to default creation): CREATE SPATIAL INDEX sixd ON spatial_table(geom_column) USING GEOGRAPHY_AUTO_GRID WITH (CELLS_PER_OBJECT = 20) 14 Use ALTER and DROP INDEX for maintenance.
  • 15.
  • 16. Geometry: STIntersects() = 1 • • STOverlaps() = 1 • STEquals()= 1 • STTouches() = 1 • • STWithin() = 1 • STContains() = 1 • STDistance() < val • STDistance() <= val Nearest Neighbor Filter() = 1
  • 17.
  • 18.
  • 19. Itself Ancestors Descendants 7 7.2 7.2.4 Spatial Index S
  • 20. Optional Sort Remove dup ranges T(@g) Ranges Spatial Index Seek
  • 21. Fully contained cells Partially contained cells
  • 22. Optimal value (theoretical) is somewhere between two extremes Default values: Time needed to 512 - Geometry AUTO grid process false positives 768 - Geography AUTO grid 1024 - SELECT * FROM table t WITH MANUAL grids (SPATIAL_WINDOW_MAX_CELLS=256) WHERE t.geom.STIntersects(@window)=1;
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. Give me the closest 5 Italian restaurants SQL Server 2008/2008 R2: table scan SQL Server 2012: uses spatial index SELECT TOP(5) * FROM Restaurants r WHERE r.type = ‘Italian’ AND r.pos.STDistance(@me) IS NOT NULL ORDER BY r.pos.STDistance(@me)
  • 29.
  • 30. Find the closest 50 business points to a specific location (out of 22 million in total)
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 38.
  • 39. Arguments Parameter Type Description @tabname nvarchar(776) the name of the table for which the index has been specified @indexname sysname the index name to be investigated @verboseoutput tinyint 0 core set of properties is reported 1 all properties are being reported @query_sample geometry A representative query sample that will be used to test the usefulness of the index. It may be a representative object or a query window. PropName: nvarchar(256) PropValue: sql_variant
  • 40. Parameter Type Description @tabname nvarchar(776) the name of the table for which the index has been specified @indexname sysname the index name to be investigated @verboseoutput tinyint 0 core set of properties is reported 1 all properties are being reported @query_sample geography A representative query sample that will be used to test the usefulness of the index. It may be a representative object or a query window. @xml_output xml This is an output parameter that contains the returned properties in an XML fragment
  • 41. Property Type Description Base_Table_Rows Bigint All Number of rows in the base table Index properties - All index properties: bounding box, grid densities, cell per object Total_Primary_Index_R Bigint All Number of rows in the index ows Total_Primary_Index_P Bigint All Number of pages in the index ages Total_Number_Of_Obje Bigint Core Indicates whether the representative query sample falls outside of the ctCells_In_Level0_For_ bounding box of the geometry index and into the root cell (level 0 cell). This is QuerySample either 0 (not in level 0 cell) or 1. If it is in the level 0 cell, then the investigated index is not an appropriate index for the query sample. Total_Number_Of_Obje Bigint Core Number of cell instances of indexed objects that are tessellated in level 0. For ctCells_In_Level0_In_I geometry indexes, this will happen if the bounding box of the index is smaller ndex 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.
  • 42. 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. Number_Of_Times_Secondary_Filter_Is_ bigint Core Number of times the secondary filter is called. Called Percentage_Of_Rows_NotSelected_By_Pri float Core Suppose there are N rows in the base table, suppose P mary_Filter are selected by the primary filter. This is (N-P)/N as percentage. Percentage_Of_Primary_Filter_Rows_Sele float Core This is S/P as a percentage. The higher the percentage, cted_By_Internal_Filter the better is the index in avoiding the more expensive secondary filter. Number_Of_Rows_Output bigint Core O=Number of rows output by the query. Internal_Filter_Efficiency float Core This is S/O as a percentage. 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.
  • 43.
  • 44.
  • 45.
  • 46. http://social.technet.microsoft.com/wiki/contents/articles/updated-spatial-features-in-the-sql- azure-q4-2011-service-release.aspx Forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1629&SiteID=1

Editor's Notes

  1. ADD USING Syntax to show new tessellation scheme
  2. Procedure:Construct 4 points/ranges for each cell in TRemove duplicatesSort (optionally)Seek
  3. Clustering imposes ordering on index
  4. Procedure:Construct 4 points/ranges for each cell in TRemove duplicatesSort (optionally)Seek
  5. TB
  6. ADD Tesselation
  7. Experimentation: For instance, consider this dataset: US Highways.  In this dataset some of the LineStrings are quite long (over 2000 miles) and others are quite short (400 meters or less). For optimal performance, the following two indexes were roughly equivalent:Geography Index: MEDIUM, MEDIUM, MEDIUM, MEDIUM 1024Geometry Index: LOW, LOW, LOW, LOW 1024