Hypothetical aggregates in SQL

The question raised here is whether the ordering of elements returned by array_agg has changed because of the quicksort and binary search used by the planner.

The plan shown illustrates the shape of the execution:

  • GroupAggregate, with the group key ((x % 2))
  • Below it a Sort on the same key, using quicksort with 25kB of memory
  • Below that a Function Scan on generate_series x

The plan reports two output rows and a planning time of 0.081 ms, against an execution time of 0.122 ms.

Reply