Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZLKHK-0003tw-IF for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Aug 2015 00:03:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZLKHJ-000661-Rb for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Aug 2015 00:03:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZLKHI-00065o-BI for pgsql-bugs@postgresql.org; Sat, 01 Aug 2015 00:03:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZLKHF-0007EL-Bk for pgsql-bugs@postgresql.org; Sat, 01 Aug 2015 00:03:51 +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 t7103f9s013925; Fri, 31 Jul 2015 20:03:42 -0400 From: Tom Lane To: "Peter J. Holzer" cc: pgsql-bugs@postgresql.org Subject: Re: 9.5alpha1: Partial index not used In-reply-to: <20150731173213.GB2423@hjp.at> References: <20150731173213.GB2423@hjp.at> Comments: In-reply-to "Peter J. Holzer" message dated "Fri, 31 Jul 2015 19:32:14 +0200" Date: Fri, 31 Jul 2015 20:03:41 -0400 Message-ID: <13924.1438387421@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "Peter J. Holzer" writes: > Consider this table: > ... > "concept_start_idx" btree (start) WHERE start IS NOT NULL > and this query: > select id as IdValue, canonicalname as Description, null as IsLeaf from public.concept where start; > Clearly this should be able to use the partial index (if start is true > it is also not null) As you surmise, there's no proof rule for that. > and since there are only 3 out of 3 million rows in > result it would also be beneficial (and PostgreSQL 9.1 did use the > index). ... and there wasn't in 9.1 either. I get a seqscan from examples like this in every branch back to 8.3, which is as far back as I can test conveniently. This is the exact test case I'm using: create table foo as select null::bool as start, generate_series(1,100000) as x; update foo set start = true where x < 10; create index foos on foo (start) where start is not null; analyze foo; explain select * from foo where start; explain select * from foo where start = true; explain select * from foo where start is not null; Only the last case produces use of the index. I agree that it'd be better if they all did, but I'm disinclined to consider it a bug fix unless you can show a specific case in which there's a performance regression from older releases. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs