Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 012392E34CD for ; Wed, 12 Dec 2007 20:37:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 16288-08 for ; Wed, 12 Dec 2007 20:37:42 -0400 (AST) Received: from web31808.mail.mud.yahoo.com (web31808.mail.mud.yahoo.com [68.142.207.71]) by postgresql.org (Postfix) with SMTP id D92712E00E7 for ; Wed, 12 Dec 2007 20:37:46 -0400 (AST) Received: (qmail 88436 invoked by uid 60001); 13 Dec 2007 00:37:45 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=g+iR/r+b6FcBub4fLZUJX2CISyUx+OMO+tIdAMQtGDu8zWd9scqv3TrdWzYKgU2JS3L79v/Drd6ajvpvRMCGa2R6TO0mEdrOBfr+a4LnxUDDDazoB39GPTIRogdPkRF9wNMAdw4DHY4nzKXhtrXXLBvyA9a9Uc1X7DpHKw5S1Lc=; X-YMail-OSG: llEwplQVM1meoIC7Rs9HzxCfxHXGn1nLBrN929gA6YugQXH2kfKv3MEQHLthYrE2_FFa1DL9PQ-- Received: from [75.84.89.248] by web31808.mail.mud.yahoo.com via HTTP; Wed, 12 Dec 2007 16:37:45 PST X-Mailer: YahooMailWebService/0.7.162 Date: Wed, 12 Dec 2007 16:37:45 -0800 (PST) From: Richard Broersma Jr Subject: Re: WHERE clause OR vs IN To: Medi Montaseri Cc: pgsql-admin@postgresql.org In-Reply-To: <8078a1730712121530r70a520e1qf9c09b516db54b0e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <359993.87392.qm@web31808.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/74 X-Sequence-Number: 27591 --- On Wed, 12/12/07, Medi Montaseri wrote: > based on your report, run time of OR is 0.275 ms and IN is > 0.314 > > > postgres=# explain analyze select * from tellers where > bid in ('1','2'); Two other options are: SELECT * FROM Tellers WHERE bin = ANY( '1', '2' ); and SELECT T.* FROM Tellers AS T INNER JOIN ( VALUES ( '1' ), ( '2' ) ) AS B( bin ) ON T.bin = B.bin; Regards, Richard Broersma Jr.