From: Tom Lane <tgl@sss.pgh.pa.us>
To: Danny Shemesh <dany74q@gmail.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Index only scans for expressional indices when querying for the expression
Date: Thu, 04 Aug 2022 09:38:36 -0400
Message-ID: <3435275.1659620316@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFZC=Qo-4c8o4bg9qzCUf65wZucKkjP+ZEJa2R05G__f_Ht8cQ@mail.gmail.com>
References: <CAFZC=QqFpth2mCw=vQHak_mpcY9s_M3HVP6TgChAdf6Lnq_bEg@mail.gmail.com>
<CAKFQuwZTD0NydFg8Ra4kUuU2WDxY53FCx9Zh6_OwVjdCLThp8w@mail.gmail.com>
<CAFZC=Qo-4c8o4bg9qzCUf65wZucKkjP+ZEJa2R05G__f_Ht8cQ@mail.gmail.com>
Danny Shemesh <dany74q@gmail.com> writes:
> That is of course correct, but what I mean is that, I think that if one
> would explicitly query f(x), and never for x directly, it would've been
> theoretically possible to say that the index is covering for every f(x),
> wouldn't it ?
Theoretically, yeah, but we don't support that: an index-only scan
will only be considered if x itself is available from the index.
There are a couple of reasons for that, but the main one is that
detecting whether an index matches the query would be far more expensive
if it had to consider expression subtrees not just the base Vars.
regards, tom lane
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, dany74q@gmail.com, david.g.johnston@gmail.com
Subject: Re: Index only scans for expressional indices when querying for the expression
In-Reply-To: <3435275.1659620316@sss.pgh.pa.us>
References: <CAFZC=QqFpth2mCw=vQHak_mpcY9s_M3HVP6TgChAdf6Lnq_bEg@mail.gmail.com> <CAKFQuwZTD0NydFg8Ra4kUuU2WDxY53FCx9Zh6_OwVjdCLThp8w@mail.gmail.com> <CAFZC=Qo-4c8o4bg9qzCUf65wZucKkjP+ZEJa2R05G__f_Ht8cQ@mail.gmail.com> <3435275.1659620316@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