Spatialoow10 Bestpractices
Spatialoow10 Bestpractices
UPDATE roads_13356
SET geom = sdo_util.rectify_geometry (geom, tolerance) ;
SELECT sdo_tune.estimate_rtree_index_size
(250000, 8192, 15, 2, 1)
FROM dual;
• SDO_FILTER
• SDO_RELATE
• SDO_ANYINTERACT
• SDO_WITHIN_DISTANCE
• SDO_NN
• SDO_INSIDE
• SDO_OVERLAPS
• SDO_TOUCH
• SDO_EQUAL
• Etc…
Spatial Operators – Template
For Example:
SELECT a.customer_name, a.phone_number
FROM policy_holders a
WHERE sdo_within_distance(a.geom, hurricane_path_geom,
‘distance = 10 unit = mile’) = ‘TRUE’;
Spatial Operators – Ordered Hint
• When query window comes from a table, use the
ORDERED hint.
• ORDERED hint is not a spatial specific
• Hints the optimizer to use indexes on tables as they
are listed in the FROM clause
• Execution plan tracing is important
For Example:
SELECT /*+ ordered */
i.highway
FROM geod_states s,
geod_interstates i
WHERE s.state = 'Arizona'
AND sdo_relate (i.geom, s.geom,'mask=ANYINTERACT')='TRUE';
Look At Your Execution Plan
From SQL*Plus:
When possible
make the query window a polygon.
Nearest Neighbor – SDO_NN
• Very effective way to find geometries closest to a
window geometry.
• For example, find the five closest banks to my location.
• SDO_NUM_RES or SDO_BATCH_SIZE parameter,
which should you use?
• SDO_NUM_RES
• When only proximity is considered (closest bank example above)
• SDO_BATCH_SIZE
• When other columns from the same table as the nearest
neighbor search column are considered in the WHERE clause.
• For example, find the five closest banks named Citibank.
• The Bank table’s geometry and bank_name columns are being
searched.
SDO_NN Example – With SDO_NUM_RES
SELECT b.bank_name,
sdo_nn_distance (1) distance
FROM banks_table b
WHERE sdo_nn (b.geom, :my_hotel,
'SDO_NUM_RES=5‘ , 1) = 'TRUE';
SDO_NN Example – With SDO_BATCH_SIZE
SELECT b.bank_name,
sdo_nn_distance (1) distance
FROM banks_table b
WHERE sdo_nn (b.geom, :my_hotel,
'SDO_NUM_RES=5 DISTANCE=2 UNIT=mile ' , 1) = 'TRUE';
SDO_NN – Recommended patches
• Easy to use
Javascript API
• No plug-ins
• Sample data
with many
demos.
• Demos include
source code.
Oracle Maps – Basemap Best
Practices
• Prefetch tiles – If possible, devote hardware… can
take days, plan ahead.
• Maximize tile generation throughput:
• Increase the number of concurrent threads fetching tiles.
• To do this, adjust MapViewer configuration parameter
concurrent_fetching_threads (default 4):
• <map_tile_layer name="DEMO_MAP“
image_format="PNG" http_header_expires="168.0"
concurrent_fetching_threads="4">
...
</map_tile_layer>
Oracle Maps – Basemap Best
Practices (continued)
• Maximize tile generation throughput – (continued)
• Monitor middle tire and database servers when adjusting
concurrent_fetching_threads.
• Easiest way is to monitor CPU usage.
• Consider increasing resources for overloaded middle tier or
database servers, for example:
• Add node(s) to a RAC
• Faster CPUs
• More memory
• The optimal workload should be 60%-80% of the server
capacity.
Oracle Maps – Basemap Best
Practices (continued)
• Basemap design:
• For faster tile generation, keep basemap simple and efficient
• Only display necessary layers at each zoom level
• Set map scale for dense layers. Only turn detailed roads on
when zoomed in.
• When rendering geometries of a theme differently based on an
attribute value:
• Use an advanced style instead of multiple styling rules.
• Multiple styling rules issues an SDO_FILTER for each rule.
• An advanced style issues one SDO_FILTER, and the
MapViewer client decides how to render each geometry
based on an associated attribute column value.
Oracle Maps – Dynamic Layers Best Practices
• MVThemeBasedFOI.setBoundingTheme verse
MVThemeBasedFOI.zoomToTheme
• Both zoom map to the extent of the theme.
• MVThemeBasedFOI.setBoundingTheme – Use this the first
time you add theme to the display..
• MVThemeBasedFOI.zoomToTheme – Use this if the theme is
already added to the display
Oracle Maps – Dynamic Layers Best Practices
(continued)
• Correct usage:
• theme.setBoundingTheme(true);
mapview.addThemeBasedFOI(theme);
• Incorrect usage:
• This will result in fetching the theme twice.
• mapview.addThemeBasedFOI(theme);
theme.zoomToTheme();
Oracle Spatial
Network Data Model
Spatial at OOW 2010 - Sessions
NetworkAnalyst.shortestPathDijkstra(…)
Network Data Model Analysis: All Paths
Between Two Nodes
NetworkAnalyst.kShortestPaths(…)
Network Data Model Analysis: All Nodes
Within Cost
NetworkAnalyst.withinCost(…)
Network Data Model Analysis:
Traveling Salesman Problem
NetworkAnalyst.tspPath(…)
Network Partitioning Best Practices
• Increase the size of the network partition cache. After the cache
is full, a Least Recently Used (LRU) algorithm is used to purge
partitions from the cache and load others.
• Increase Java heap size, for example, Java –Xmx –xms.
• Generate partition BLOBs, a binary representation of the network
partitions that make it much faster to load them into memory.
• Choose an optimal partition size. Very small partitions may result
in excessive partition loads. If partitions are too large, more data
may get loaded than is necessary to perform network analysis.
• Try to minimize the number of links between partitions.
• Leverage hierarchical networks when possible.
• If running on 11.1.0.7, apply patch 7700528 available on
metalink.
Some Patch
Recommendations
Spatial Patch Recommendations
• If possible, upgrade to 11g Release 2.
• The following patches, and patch are recommended for
bug fixes and better performance and are available on
MetaLink.
• For MapViewer:
• Use latest production version available on the MapViewer page on OTN
Q&
Find out more...
oracle.com/database/spatial.html
A
oracle.com/technology/products/spatial
oracle.com/technology/products/spatial/htdocs/pro_oracle_spatial.html