Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XmlDJ-0004hM-8W for pgsql-performance@arkaria.postgresql.org; Fri, 07 Nov 2014 15:12:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XmlDI-0007cE-6U for pgsql-performance@arkaria.postgresql.org; Fri, 07 Nov 2014 15:12:36 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XmlDH-0007c7-2w for pgsql-performance@postgresql.org; Fri, 07 Nov 2014 15:12:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XmlDE-0003oL-05 for pgsql-performance@postgresql.org; Fri, 07 Nov 2014 15:12:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sA7FBmj5003341; Fri, 7 Nov 2014 10:11:48 -0500 From: Tom Lane To: Kevin Grittner cc: Andrew Dunstan , Vlad Arkhipov , David Rowley , pgsql-performance Subject: Re: Postgres does not use indexes with OR-conditions In-reply-to: <1415369851.48766.YahooMailNeo@web122305.mail.ne1.yahoo.com> References: <545C479B.7010104@dc.baikal.ru> <545C5352.4050309@dc.baikal.ru> <545CCF54.1010205@dunslane.net> <1415369851.48766.YahooMailNeo@web122305.mail.ne1.yahoo.com> Comments: In-reply-to Kevin Grittner message dated "Fri, 07 Nov 2014 06:17:31 -0800" Date: Fri, 07 Nov 2014 10:11:48 -0500 Message-ID: <3340.1415373108@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Kevin Grittner writes: > On the other hand, why not simply write it as?: > select * > from commons.financial_documents fd > where (fd.creation_time, fd.financial_document_id) > < ('2011-11-07 10:39:07.285022+08', 100) > order by fd.creation_time desc > limit 200 That's the way to do it, not only because it's simpler and clearer, but because the planner will recognize the relevance of the condition to an index on creation_time, financial_document_id ... regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance