X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C4568B9F29 for ; Wed, 16 Feb 2005 18:46:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33234-04 for ; Wed, 16 Feb 2005 18:46:21 +0000 (GMT) Received: from mx-00.sil.at (mx-00.sil.at [62.116.68.196]) by svr1.postgresql.org (Postfix) with ESMTP id 52B718B9FB2 for ; Wed, 16 Feb 2005 18:36:43 +0000 (GMT) Received: (qmail-ldap/ctrl 95755 invoked from network); 16 Feb 2005 18:36:40 -0000 Received: from unknown (HELO jupiter.sonorys.at) ([213.235.243.42]) (envelope-sender ) by mx-00.sil.at (qmail-ldap-1.03) with SMTP for ; 16 Feb 2005 18:36:40 -0000 Received: from neptun.sonorys.at (neptun.sonorys.at [172.24.1.17]) by jupiter.sonorys.at (8.11.7+Sun/8.11.7) with ESMTP id j1GIb6s19336 for ; Wed, 16 Feb 2005 19:37:06 +0100 (MET) Received: by neptun.sonorys.at with Internet Mail Service (5.5.2653.19) id ; Wed, 16 Feb 2005 19:36:45 +0100 Message-ID: From: =?ISO-8859-1?Q?K=D6PFERL_Robert?= To: PostgreSQL SQL Subject: Re: More efficient OR Date: Wed, 16 Feb 2005 19:36:41 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="ISO-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200502/166 X-Sequence-Number: 20277 At least for between, I read that pgSQL rewrites it to a (a -----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 >