From: KÖPFERL Robert <robert.koepferl@sonorys.at>
To: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: More efficient OR
Date: Wed, 16 Feb 2005 19:36:41 +0100
Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB165CF@neptun.sonorys.at> (raw)
At least for between, I read that pgSQL rewrites it to a (a<x) AND (x<b).
And my experience shows that IN is translated into a series of ORs.
I may be wrong
> -----Original Message-----
> From: Keith Worthington [mailto:keithw@narrowpathinc.com]
> Sent: Mittwoch, 16. Februar 2005 17:36
> To: PostgreSQL SQL
> Cc: Sean Davis; Scott Marlowe
> Subject: Re: [SQL] More efficient OR
>
>
> > > Hi All,
> > >
> > > In several of my SQL statements I have to use a WHERE clause
> > > that contains mutiple ORs. i.e.
> > >
> > > WHERE column1 = 'A' OR
> > > column1 = 'B' OR
> > > column1 = 'C'
> > >
> > > Is there a more efficient SQL statement that accomplishes the
> > > same limiting functionality?
> > >
> > > Kind Regards,
> > > Keith
> > >
> >
> > Scott wrote:
> > The in() construct is (nowadays) basically the same as
> > ORing multiple columns;
> >
> > where column1 in ('A','B','C')
> >
> >
> > Sean Davis wrote
> > Could 'in' or 'between' do what you want? I know that using 'in'
> > is equivalent to what you have below. Could 'between' be more
> > efficient--you could do explain analyze on various options to see
> > what the actual plan would be.
> >
> > Sean
>
> Thanks Scott and Sean for the post.
>
> It sounds like IN will save some typing and code space but
> not decrease the
> execution time.
>
> BETWEEN won't work for my real life query because the
> limiting values are
> quite disparate.
>
> Kind Regards,
> Keith
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
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: robert.koepferl@sonorys.at
Subject: Re: More efficient OR
In-Reply-To: <ED4E30DD9C43D5118DFB00508BBBA76EB165CF@neptun.sonorys.at>
* 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