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

From Tom Lane
Subject Re: BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data
Date
Msg-id 13813.1423691859@sss.pgh.pa.us
Whole thread Raw
In response to BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data  (toruvinn@lain.pl)
List pgsql-bugs
toruvinn@lain.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

pgsql-bugs by date:

Previous
From: toruvinn@lain.pl
Date:
Subject: BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #12755: pg_upgrage creates potentially dangerous delete_old_cluster.bat