6

When using array_agg or array_string, the array returns empty above a certain size.

SELECT array_agg(x.id) FROM (SELECT id FROM table LIMIT 500) x - this works and returns an array.

but this query : SELECT array_agg(x.id) FROM (SELECT id FROM table LIMIT 667) x Doesn't work. it returns an empty array.

i'm pretty sure this doesn't reach the limitation size of an array. Any ideas why is this happening?

3
  • 1
    @a_horse_with_no_name no. try SELECT array_agg(x.id) FROM (SELECT * FROM cast(generate_series(1,1158) as int)as id) x Commented Sep 13, 2012 at 8:20
  • 3
    I found out what was the issue. the limitation is in the display environment. pgAdmin III doesn't display the data in the UI, but it's there. Commented Sep 13, 2012 at 8:28
  • 1
    @Ereli When the timer permits you to, please add that as an answer to your question and accept it. Commented Sep 13, 2012 at 8:33

1 Answer 1

5

the issue here was not Postgresql, but rather the client I was using. pgAdmin III doesn't display the content of array over a certain size. about 4.5k. when using psql one doesn't encounter the same issue.

the the UI of pgAdmin there is an option to set "Max characters per column" and it was set to 256 in my case, which makes little sense. but you copy & paste the array that looks empty into notepad you'll find the all the data is there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.