Oracle 5.0 Reference Manual page 1019

Table of Contents

Advertisement

• With
CREATE
CREATE TABLE geom (g GEOMETRY NOT NULL, SPATIAL INDEX(g)) ENGINE=MyISAM;
• With
ALTER
ALTER TABLE geom ADD SPATIAL INDEX(g);
• With
CREATE
CREATE SPATIAL INDEX sp_index ON geom (g);
For
MyISAM
nonspatial indexing of spatial columns, the engine creates a B-tree index. A B-tree index on spatial
values will be useful for exact-value lookups, but not for range scans.
For more information on indexing spatial columns, see
To drop spatial indexes, use
• With
ALTER
ALTER TABLE geom DROP INDEX g;
• With
DROP
DROP INDEX sp_index ON geom;
Example: Suppose that a table
column
of type GEOMETRY. The table also has an
g
ID values.
mysql>
DESCRIBE geom;
+-------+----------+------+-----+---------+----------------+
| Field | Type
+-------+----------+------+-----+---------+----------------+
| fid
| int(11)
| g
| geometry |
+-------+----------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql>
SELECT COUNT(*) FROM geom;
+----------+
| count(*) |
+----------+
|
32376 |
+----------+
1 row in set (0.00 sec)
To add a spatial index on the column g, use this statement:
mysql>
ALTER TABLE geom ADD SPATIAL INDEX(g);
Query OK, 32376 rows affected (4.05 sec)
Records: 32376
12.16.6.2. Using a Spatial Index
The optimizer investigates whether available spatial indexes can be involved in the search for queries
that use a function such as
The following query finds all objects that are in the given rectangle:
mysql>
SET @poly =
->
'Polygon((30000 15000,31000 15000,31000 16000,30000 16000,30000 15000))';
mysql>
SELECT fid,AsText(g) FROM geom WHERE
->
MBRContains(GeomFromText(@poly),g);
+-----+---------------------------------------------------------------+
| fid | AsText(g)
+-----+---------------------------------------------------------------+
Optimizing Spatial Analysis
TABLE:
TABLE:
INDEX:
tables,
SPATIAL INDEX
ALTER TABLE
TABLE:
INDEX:
geom
| Null | Key | Default | Extra
|
| PRI | NULL
|
|
Duplicates: 0
Warnings: 0
MBRContains()
creates an R-tree index. For storage engines that support
Section 13.1.8,
or
DROP
INDEX:
contains more than 32,000 geometries, which are stored in the
AUTO_INCREMENT
| auto_increment |
|
[996]
or
MBRWithin()
999
"CREATE INDEX
column
for storing object
fid
|
|
[997]
in the
WHERE
|
Syntax".
clause.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents