pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Anish Kejariwal <anishkej@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: pass in array to function for use by where clause? how optimize?
Date: Wed, 13 Apr 2011 11:09:23 -0400
Message-ID: <5079.1302707363@sss.pgh.pa.us> (raw)
In-Reply-To: <BANLkTinHyTWh-HZPm0XoTqYEtEqJ8T-iRw@mail.gmail.com>
References: <BANLkTinHyTWh-HZPm0XoTqYEtEqJ8T-iRw@mail.gmail.com>

Anish Kejariwal <anishkej@gmail.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



view thread (5+ messages)  latest in thread

Message-ID: <5079.1302707363@sss.pgh.pa.us>
Permalink:  ../5079.1302707363@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5079.1302707363@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, anishkej@gmail.com
  Subject: Re: pass in array to function for use by where clause? how optimize?
  In-Reply-To: <5079.1302707363@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox