Oracle’s SDO_AGGR_UNION has always had horrible performance where the set of geometry objects to be unioned is somewhat more than trivial.
(Trivial is not a well defined scientific term – experienced users of Oracle Spatial know what I am interfering.)
The Oracle Spatial team were not unaware of the problems with their aggregate function. To be fair on them, the problem lies with the kernel and not their implementation. The problem has to do with the size of the CONTEXT that can be sorted. To get around this, the spatial team’s SDO_AGGR_UNION function errs on the side of completion as against speed of execution.
To get around the problems, the Oracle Spatial team introduced the SDO_AGGR_UNION function.
Yet incorrect use of this function can cause a failure of the SQL as can be seen in the following example:
22813. 00000 -"operand value exceeds system limits"
*Cause: Object OR Collection VALUE was too LARGE. The SIZEOF the VALUE
might have exceeded 30k IN a SORT context,OR the SIZE might be
too big FOR available memory.
*Action: Choose another VALUEAND retry the operation.
To be fair on the Oracle Spatial team this is not their preferred method for executing this function (see documentation). In my view, though, it is the most natural given normal SQL use.
Still, the preferred method is to create an “aggregation function” as in the following example:
CREATEORREPLACEFUNCTION Set_Geometry_by_Value(p_value IN varchar2)
RETURN SDO_GEOMETRY_ARRAY
deterministic
AS
c_query SYS_REFCURSOR;
v_g sdo_geometry;
v_GeomArr sdo_geometry_array;
BEGIN
v_GeomArr := SDO_GEOMETRY_ARRAY();
OPEN c_query FOR'select a.geometry from administration a where a.group_code = :1'
But this still is not that natural given the need to repeat the statement for the grouping value.
So, while SDO_AGGR_SET_UNION can be made more flexible it is a solution that really has no future as the only solution is to make SDO_AGGR_UNION perform as quickly as Oracle’s competitors because they all do better than Oracle.
Comment