Re: pass in array to function for use by where clause? how optimize?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Anish Kejariwal <anishkej(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: pass in array to function for use by where clause? how optimize?
Date: 2011-04-13 15:09:23
Message-ID: 5079.1302707363@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Anish Kejariwal <anishkej(at)gmail(dot)com> writes:
> (select store_id, avg(sales) sales
> from store
> where group_id in(select $1[i] from generate_subscripts($1, 1) g(i))

Seems like a pretty brute-force way to deal with the array. Try

where group_id = any($1)

Not sure if it'll be a great deal faster, but it's at least easier to
write.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2011-04-13 15:48:27 Re: pass in array to function for use by where clause? how optimize?
Previous Message Tom Lane 2011-04-13 14:52:32 Re: unnesting of array of different size explodes memory