Another approach to consider is using strings. E.g. The function assembles the
underlying query as a string and returns the results of executing the string.
Passing the groups in a string may be straightforward in your application, or
not.
There was a thread in the novice forum last year abou
Andreas Gaab writes:
> As I now understand, the following query leads to 12 results, not just 4 (or
> 3...):
> SELECT unnest(ARRAY[1,2,3]), unnest(ARRAY[4,5,6,7]);
> Why could postgres use as much memory till the kernel complained when
> unnesting 1200 and 1300 elements resulting in 1.6e6 rows