postgresql select ids into array