25.04.2013 Views

View PDF

View PDF

View PDF

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Returns<br />

Usage Notes<br />

SDO_RELATE<br />

The expression SDO_RELATE(geometry1,geometry2, 'mask = ') =<br />

'TRUE' evaluates to TRUE for object pairs that have the topological relationship<br />

specified by , and FALSE otherwise.<br />

The operator is disabled if the table does not have a spatial index or if the number of<br />

dimensions for the query window does not match the number of dimensions specified<br />

when the index was created.<br />

The operator must always be used in a WHERE clause, and the condition that includes<br />

the operator should be an expression of the form SDO_RELATE(arg1, arg2, 'mask =<br />

') = 'TRUE'.<br />

geometry2 can come from a table or be a transient SDO_GEOMETRY object, such as<br />

a bind variable or SDO_GEOMETRY constructor.<br />

■ If the geometry2 column is not spatially indexed, the operator indexes the query<br />

window in memory and performance is very good.<br />

■ If two or more geometries from geometry2 are passed to the operator, the<br />

ORDERED optimizer hint must be specified, and the table in geometry2 must be<br />

specified first in the FROM clause.<br />

If geometry1 and geometry2 are based on different coordinate systems, geometry2<br />

is temporarily transformed to the coordinate system of geometry1 for the operation<br />

to be performed, as described in Section 6.10.1.<br />

Unlike with the SDO_GEOM.RELATE function, DISJOINT and DETERMINE masks<br />

are not allowed in the relationship mask with the SDO_RELATE operator. This is<br />

because SDO_RELATE uses the spatial index to find candidates that may interact, and<br />

the information to satisfy DISJOINT or DETERMINE is not present in the index.<br />

Although multiple masks can be combined using the logical Boolean operator OR, for<br />

example, 'mask=touch+coveredby', better performance may result if the spatial<br />

query specifies each mask individually and uses the UNION ALL syntax to combine<br />

the results. This is due to internal optimizations that Spatial can apply under certain<br />

conditions when masks are specified singly rather than grouped within the same<br />

SDO_RELATE operator call. (There are two exceptions, inside+coveredby and<br />

contains+covers, where the combination performs better than the UNION ALL<br />

alternative.) For example, consider the following query using the logical Boolean<br />

operator OR to group multiple masks:<br />

SELECT a.gid<br />

FROM polygons a, query_polys B<br />

WHERE B.gid = 1<br />

AND SDO_RELATE(A.Geometry, B.Geometry,<br />

'mask=touch+coveredby') = 'TRUE';<br />

The preceding query may result in better performance if it is expressed as follows,<br />

using UNION ALL to combine results of multiple SDO_RELATE operator calls, each<br />

with a single mask:<br />

SELECT a.gid<br />

FROM polygons a, query_polys B<br />

WHERE B.gid = 1<br />

AND SDO_RELATE(A.Geometry, B.Geometry,<br />

'mask=touch') = 'TRUE'<br />

UNION ALL<br />

SELECT a.gid<br />

Spatial Operators 19-31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!