SELECT array_accum(x) FROM (SELECT * FROM some_view ORDER BY x) AS tmp;

If you're using integers, you could use the int_array_accum or something from the intarray module which is a lot faster.
I believe intarray also has a function for sorting integer arrays...



BTW, the best alternative (in terms of execution performance) that comes into my mind is to create an aggregate that does the sorting right away while the values "come in" from the rows. But that'd probably take me some time to get right.




---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend

Reply via email to