Bart Grantham wrote:
> Hello again. I had a problem a few weeks ago with using IN ( some_array
> ) having really rough performance. Special thanks to Ron Mayer for the
> suggestion of using int_array_enum(some_array) to join against. I had
> to upgrade to PG8 but that technique works really well. Now I have a
> question about array manipulation. Specifically, how can I build an
> array from the result of a query without resorting to array_append()?
Well, the same contrib module with int_array_enum() also has
aggregate called int_array_aggregate that turns a column into an array.
> -- my_array is an INT[]
>
> _my_array := select some_column from some_table;
so this:
SELECT int_array_aggregate(some_column) from some_table;
might be what you want.
> ... in plpgsql?
Well... the function from the contrib module was in C, so I guess
it doesn't strictly meet what you asked, but it works very well
for me. ;-)
Ron Mayer
PS: the stuff in /contrib/intarray may be useful too, for
indexing, merging, and many other tricks on the integer arrays.