Professional Documents
Culture Documents
Spatial Tuning
After
After completing
completing this this lesson,
lesson, you
you should
should
be
be able
able to
to do
do the
the following:
following:
• Determine
Determine thethe appropriate
appropriate quadtree
quadtree
indexing
indexing level
level for
for aa layer
layer
• Look
Look atat quadtree
quadtree index
index structures
structures and
and
determine
determine their
their efficiency
efficiency
• Verify
Verify the
the validity
validity ofof geometries,
geometries, or
or of
of an
an
entire
entire layer
layer
• The
The SDO_TUNE
SDO_TUNE package
package
–– Spatial
Spatial data
data analysis
analysis
–– Tune
Tune spatial
spatial indexes
indexes
• The
The SDO_GEOM
SDO_GEOM package
package
–– Validating
Validating geometries
geometries
• Manual
Manual analysis
analysis
• Enterprise
Enterprise Manager
Manager
–– Spatial
Spatial Index
Index Advisor
Advisor
Copyright Intergraph Hong Kong Limited, ®
• SDO_TUNE.ESTIMATE_TILING_LEVEL
SDO_TUNE.ESTIMATE_TILING_LEVEL
–– Gives
Gives aa starting
starting point
point to
to help
help determine
determine an
an
appropriate
appropriate tiling
tiling level
level (SDO_LEVEL)
(SDO_LEVEL) forfor
creating
creating fixed-size
fixed-size index
index tiles.
tiles.
• SDO_TUNE.AVERAGE_MBR
SDO_TUNE.AVERAGE_MBR
–– Calculates
Calculates the
the average
average minimum
minimum bounding
bounding
rectangle
rectangle for
for geometries
geometries in
in aa layer.
layer.
• SDO_TUNE.EXTENT_OF
SDO_TUNE.EXTENT_OF
–– Determines
Determines the
the minimum
minimum bounding
bounding rectangle
rectangle
of
of the
the data
data in
in aa layer.
layer.
level
level :=
:= MDSYS.SDO_TUNE.ESTIMATE_TILING_LEVEL
MDSYS.SDO_TUNE.ESTIMATE_TILING_LEVEL
(( <table-name>,
<table-name>, <column-name>,
<column-name>,
<number-tiles>,
<number-tiles>,
<type-of-estimate>
<type-of-estimate> ))
• <table-name>
<table-name> and and <column-name>
<column-name> identify
identify
the
the spatial
spatial layer.
layer.
• <number-tiles>
<number-tiles> is is the
the number
number ofof tiles
tiles
desired
desired
• <type-of-estimate>
<type-of-estimate> defines
defines the
the type
type ofof
estimation
estimation toto perform
perform
Copyright Intergraph Hong Kong Limited, ®
•• Extent
Extent of
of the
the entire
entire LAYER_EXTENT
layer
layer
•• Extent
Extent surrounding
surrounding all
all ALL_GID_EXTENT
geometries
geometries
•• Extent
Extent surrounding
surrounding AVG_GID_EXTENT
the
the average
average size
size
geometry
geometry
select
select mdsys.sdo_tune.estimate_tiling_level
mdsys.sdo_tune.estimate_tiling_level ((
'STATES',
'STATES', 'GEOM',
'GEOM', 10000,
10000, 'ALL_GID_EXTENT')
'ALL_GID_EXTENT')
from
from dual;
dual;
select
select mdsys.sdo_tune.estimate_tiling_level
mdsys.sdo_tune.estimate_tiling_level ((
'STATES',
'STATES', 'GEOM',
'GEOM', 4,
4, 'AVG_GID_EXTENT')
'AVG_GID_EXTENT')
from
from dual;
dual;
B B B
B I I B B
B I I I I B
B I I I I B
B I I I I B
B I I I B
B I B B B
B B B
DEMO
•• For
For very
very large
large quadtree
quadtree spatial
spatial index
index tables,
tables, you
you can
can
estimate
estimate 11 percent
percent (if
(if you
you don’t
don’t have
have the
the time
time to
to
compute
compute statistics).
statistics).
SQL>
SQL> select
select ‘ANALYZE
‘ANALYZE TABLE
TABLE ‘‘ ||
|| SDO_INDEX_TABLE
SDO_INDEX_TABLE ||
||
22 ‘‘ estimate
estimate statistics
statistics sample
sample 11 percent;
percent; ‘‘
33 from
from user_sdo_index_metadata;
user_sdo_index_metadata;
Copyright Intergraph Hong Kong Limited, ®
• Iterative
Iterative Process
Process (for
(for quadtree
quadtree indexes)
indexes)
–– Create
Create quadtree
quadtree index
index
–– View
View data
data at
at dense
dense location
location
–– Zoom
Zoom to
to reasonable
reasonable size
size
–– If
If too
too large
large an
an area,
area, choose
choose aa higher
higher
number
number SDO_LEVEL
SDO_LEVEL (smaller
(smaller tiles)
tiles)
–– If
If too
too small
small an
an area,
area, choose
choose aa lower
lower
number
number SDO_LEVEL
SDO_LEVEL (larger
(larger tiles)
tiles)
MDSYS.SDO_TUNE.AVERAGE_MBR
MDSYS.SDO_TUNE.AVERAGE_MBR
(( <table-name>,
<table-name>, <column-name>,
<column-name>,
<width>,
<width>, <height>
<height> ))
• <table-name>
<table-name> andand <column-name>
<column-name> identify
identify
the
the spatial
spatial layer.
layer.
• <width>
<width> and
and <height>
<height> return
return the
the width
width and
and
height
height of
of the
the average
average geometry
geometry
<geometry>
<geometry> :=
:= MDSYS.SDO_TUNE.EXTENT_OF
MDSYS.SDO_TUNE.EXTENT_OF
(( <table-name>,
<table-name>, <column-name>
<column-name> ))
• <table-name>
<table-name> andand <column-name>
<column-name> identify
identify
the
the spatial
spatial layer.
layer.
• <geometry>
<geometry> returns
returns aa rectangle
rectangle that
that
defines
defines the
the extent
extent of
of the
the layer.
layer.
SELECT
SELECT
mdsys.sdo_tune.extent_of('STATES','GEOM')
mdsys.sdo_tune.extent_of('STATES','GEOM')
FROM
FROM dual;
dual;
• SDO_GEOM.VALIDATE_GEOMETRY
SDO_GEOM.VALIDATE_GEOMETRY
–– Determines
Determines if
if aa geometry
geometry is
is valid.
valid.
• SDO_GEOM.VALIDATE_LAYER
SDO_GEOM.VALIDATE_LAYER
–– Determines
Determines if
if all
all the
the geometries
geometries stored
stored in
in aa
column
column are
are valid.
valid.
• <geometry>
<geometry> == SDO_GEOMETRY
SDO_GEOMETRY that that holds
holds
the
the object
object to
to verify
verify
–– can
can be
be aa variable
variable or
or table
table column
column
• <diminfo>
<diminfo> == dimensions
dimensions array
array
• returns
returns == an
an Oracle
Oracle error
error number
number oror TRUE
TRUE
if
if valid,
valid, or
or FALSE
FALSE if
if invalid
invalid for
for unknown
unknown
reason
reason
Copyright Intergraph Hong Kong Limited, ®
MDSYS.SDO_GEOM.VALIDATE_LAYER
MDSYS.SDO_GEOM.VALIDATE_LAYER
(( <table-name>,
<table-name>, <column-name>
<column-name>
<key-column>,
<key-column>, <result-table>)
<result-table>)
• <table-name>
<table-name> and and <column-name>
<column-name> identify
identify
the
the layer
layer to
to verify
verify
• <key-column>
<key-column> is is the
the name
name of
of the
the primary
primary
key
key ofof that
that table
table
–– Must
Must bebe aa NUMBER!
NUMBER!
• <result-table>
<result-table> is
is the
the name
name ofof aa table
table that
that
will
will receive
receive the
the results
results of
of the
the validation
validation
Copyright Intergraph Hong Kong Limited, ®
• Must
Must be
be manually
manually created
created prior
prior to
to using
using the
the
function
function
CREATE
CREATE TABLE
TABLE VALIDATION_RESULTS
VALIDATION_RESULTS ((
OBJECT_ID
OBJECT_ID NUMBER,
NUMBER,
OBJECT_STATE
OBJECT_STATE VARCHAR2(10)
VARCHAR2(10)
);
);
• You
You define
define column
column names
names
CREATE
CREATE TABLE
TABLE validation_results
validation_results as
as ((
SELECT
SELECT mdsys.sdo_geom.validate_geometry
mdsys.sdo_geom.validate_geometry
(s.geom,
(s.geom,
(SELECT
(SELECT diminfo
diminfo
FROM
FROM user_sdo_geom_metadata
user_sdo_geom_metadata
WHERE
WHERE table_name
table_name == 'STATES'
'STATES'
AND
AND column_name
column_name == 'GEOM'))
'GEOM')) status,
status,
STATE
STATE
FROM
FROM states
states s);
s);
SELECT
SELECT ** FROM
FROM validation_results
validation_results
WHERE
WHERE status
status <>
<> 'TRUE';
'TRUE';