Consider this example:
SELECT comment_date
, array_agg(user_id) users
, array_agg(comment) comments
FROM user_comments
GROUP BY comment_date
- Is it safe to assume that the indexes of users and comments refer to the same record (e.g., users[3] created comments[3])?
- Is it possible that the order of the two arrays may refer to different records, possibly due to performance enhancements?
I don't know enough about the internals of Postgres to trust array_agg ordering.