Optimizing Spatial Analysis
998
• Their intersection results in a geometry that has a dimension that is one less than the maximum
dimension of the two given geometries
• Their intersection is not equal to either of the two given geometries
•
Disjoint(g1,g2)
[998]
Returns 1 or 0 to indicate whether
g1
is spatially disjoint from (does not intersect)
g2
.
•
Equals(g1,g2)
[998]
Returns 1 or 0 to indicate whether
g1
is spatially equal to
g2
.
•
Intersects(g1,g2)
[998]
Returns 1 or 0 to indicate whether
g1
spatially intersects
g2
.
•
Overlaps(g1,g2)
[998]
Returns 1 or 0 to indicate whether
g1
spatially overlaps
g2
. The term spatially overlaps is used if two
geometries intersect and their intersection results in a geometry of the same dimension but not equal
to either of the given geometries.
•
Touches(g1,g2)
[998]
Returns 1 or 0 to indicate whether
g1
spatially touches
g2
. Two geometries spatially touch if the
interiors of the geometries do not intersect, but the boundary of one of the geometries intersects
either the boundary or the interior of the other.
•
Within(g1,g2)
[998]
Returns 1 or 0 to indicate whether
g1
is spatially within
g2
. This tests the opposite relationship as
Contains()
[997]
.
12.16.6. Optimizing Spatial Analysis
For
MyISAM
tables, Search operations in nonspatial databases can be optimized using
SPATIAL
indexes. This is true for spatial databases as well. With the help of a great variety of multi-dimensional
indexing methods that have previously been designed, it is possible to optimize spatial searches. The
most typical of these are:
• Point queries that search for all objects that contain a given point
• Region queries that search for all objects that overlap a given region
MySQL uses R-Trees with quadratic splitting for
SPATIAL
indexes on spatial columns. A
SPATIAL
index is built using the MBR of a geometry. For most geometries, the MBR is a minimum rectangle that
surrounds the geometries. For a horizontal or a vertical linestring, the MBR is a rectangle degenerated
into the linestring. For a point, the MBR is a rectangle degenerated into the point.
It is also possible to create normal indexes on spatial columns. In a non-
SPATIAL
index, you must
declare a prefix for any spatial column except for
POINT
columns.
MyISAM
supports both
SPATIAL
and non-
SPATIAL
indexes. Other storage engines support
non-
SPATIAL
indexes, as described in
Section 13.1.8, “
CREATE INDEX
Syntax”
.
12.16.6.1. Creating Spatial Indexes
For
MyISAM
tables, MySQL can create spatial indexes using syntax similar to that for creating regular
indexes, but extended with the
SPATIAL
keyword. Currently, columns in spatial indexes must be
declared
NOT NULL
. The following examples demonstrate how to create spatial indexes:
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...