Re: Index only scans for expressional indices when querying for the expression

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Danny Shemesh <dany74q(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Index only scans for expressional indices when querying for the expression
Date: 2022-08-04 13:38:36
Message-ID: 3435275.1659620316@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Danny Shemesh <dany74q(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Wiwwo Staff 2022-08-04 13:42:00 Allow user to connect to replicas only
Previous Message Aleš Zelený 2022-08-04 12:34:10 Re: PostgreSQL 14.4 ERROR: out of memory issues