Uploaded image for project: 'Apache Sedona'
  1. Apache Sedona
  2. SEDONA-630

Improve ST_Union_Aggr performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None

    Description

      The function ST_Union_Aggr is slow. This is because this function is implemented in the most inefficient way: union geometry one after another.

      ```scala
      class ST_Union_Aggr extends Aggregator[Geometry, Geometry, Geometry] with TraitSTAggregateExec {

        def reduce(buffer: Geometry, input: Geometry): Geometry =

      {     if (buffer.equalsExact(initialGeometry)) input     else buffer.union(input)   }

        def merge(buffer1: Geometry, buffer2: Geometry): Geometry =

      {     if (buffer1.equals(initialGeometry)) buffer2     else if (buffer2.equals(initialGeometry)) buffer1     else buffer1.union(buffer2)   }

      }
      ```

      There are multiple improvements in JTS that improved the performance of union multiple geometry objects:

      We should switch to the new `OverlayNGRobust.union` interface to get the best thing JTS provides. This also requires us to keep all reduced geometries in memory, we may maintain a buffer with maximum size, and run OverlayNGRobust.union when the maximum size is exceeded. This will help balancing the speed and memory usage.

      Attachments

        Activity

          People

            Unassigned Unassigned
            zhangfengcdt Feng Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h