Re: BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: toruvinn(at)lain(dot)pl
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data
Date: 2015-02-11 21:57:39
Message-ID: 13813.1423691859@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

toruvinn(at)lain(dot)pl writes:
> johto told me on irc it may be worth reporting it here - thanks!

Not really. See comment in check_index_only():

/*
* Check that all needed attributes of the relation are available from the
* index.
*
* XXX this is overly conservative for partial indexes, since we will
* consider attributes involved in the index predicate as required even
* though the predicate won't need to be checked at runtime. (The same is
* true for attributes used only in index quals, if we are certain that
* the index is not lossy.) However, it would be quite expensive to
* determine that accurately at this point, so for now we take the easy
* way out.
*/

This is the same reason why expression indexes are difficult to use in
index-only scans: if the query refers to f(x), the information available
to check_index_only() says that the index must be able to return the value
of "x", not "f(x)". It'd be nice to improve, but the only obvious ways to
do that would result in entirely unacceptable hits to planning speed.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2015-02-12 03:07:21 Re: BUG #12755: pg_upgrage creates potentially dangerous delete_old_cluster.bat
Previous Message toruvinn 2015-02-11 21:28:48 BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data