By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
select array_agg(arr order by ord)
from (
select (ord+ 1) / 2 as ord, array_agg(arr) as arr
from unnest(array[1,4,2,5,3,6]) with ordinality as u(arr, ord)
group by 1
) s
array_agg |
---|
{{1,4},{2,5},{3,6}} |
SELECT 1
select array(
select array_agg(unnest)
from unnest(array[1,4,2,5,3,6]) with ordinality
group by (ordinality+ 1) / 2
order by (ordinality+ 1) / 2
)
array |
---|
{{1,4},{2,5},{3,6}} |
SELECT 1