Continuous Aggregates Impact of ORDER BY

Hi,

I note that CAGGs post v2.7 supports ORDER BY keyword.

Can someone please explain the impact of this? I had assumed that CAGGs would be ordered the same as the HyperTable - primarily by the timestamp column.

If an ORDER BY is not defined in a CAGG, in what order will data be materialized in the CAGG?

Thanks in Advance

Welcome @aglover ! It impacts working with order by clauses in them, this means things like:

SELECT percentile_cont(price)
 WITHIN GROUP (ORDER BY time)

or

SELECT array_agg(foo ORDER BY time)

If you want to ORDER BY time in your final data, you can use SELECT from the continuous aggregate though: ie

SELECT * FROM mat_view_stocks_real_time
ORDER BY time_bucket

and that should work just fine.

Hi @aglover, we also have this related PR which brings more details about this: