From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-bugs@postgresql.org
Subject: Re: 9.5alpha1: Partial index not used
Date: Fri, 31 Jul 2015 20:03:41 -0400
Message-ID: <13924.1438387421@sss.pgh.pa.us> (raw)
In-Reply-To: <20150731173213.GB2423@hjp.at>
References: <20150731173213.GB2423@hjp.at>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
"Peter J. Holzer" <hjp-pgsql@hjp.at> 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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hjp-pgsql@hjp.at
Subject: Re: 9.5alpha1: Partial index not used
In-Reply-To: <13924.1438387421@sss.pgh.pa.us>
References: <20150731173213.GB2423@hjp.at> <13924.1438387421@sss.pgh.pa.us>
* 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