Re: [SQL] Prepared Statements and large where-id-in constant blocks?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: James Robinson <jlrobins(at)socialserve(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Prepared Statements and large where-id-in constant blocks?
Date: 2004-04-20 01:02:38
Message-ID: 2046.1082422958@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-sql

James Robinson <jlrobins(at)socialserve(dot)com> writes:
> where there may be anywhere between 1 and thousands of "(id = N)"
> blocks ORed together. These may be transformed to the "WHERE t1.id IN
> (X, Y, ...)" form for possibly a little performance gain (possibly --
> I've not yet checked to see if this plans better than the other, but I
> could imagine this form being parsed into the hashjoin form as opposed
> to a huge index filter form).

There is *no difference whatever*; in fact the PG parser expands an IN
clause into an OR'd list.

Possibly this is something to improve someday, but there's surely no
percentage in doing lots of work in the JDBC driver to prefer the IN
form at the moment.

regards, tom lane

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-04-20 02:57:53 Re: Prepared Statements and large where-id-in constant blocks?
Previous Message Bruce Momjian 2004-04-20 00:58:49 Re: EXECUTE command tag returns actual command

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-04-20 01:11:33 Re: relation X does not exist
Previous Message Oliver Jowett 2004-04-19 22:21:02 Re: Prepared Statements and large where-id-in constant blocks?