Thread: One of the example queries that 'could' is identical to one that 'could not'.

One of the example queries that 'could' is identical to one that 'could not'.

From
PG Doc comments form
Date:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/indexes-index-only-scans.html
Description:

11.9.2 lists ```SELECT x FROM tab WHERE x = 'key' AND z < 42;``` as both
examples of 'could' and 'could not' use index-only scans. I believe this is
what was meant:
"""""""""""""""""""
but these queries could not:

SELECT x, z FROM tab WHERE x = 'key';
SELECT x FROM tab WHERE x = 'key' AND z < 42;
"""""""""""""""""""

should read:
"""""""""""""""""""
but these queries could not:

SELECT x, z FROM tab WHERE x = 'key';
SELECT z FROM tab WHERE x = 'key' AND z < 42;
"""""""""""""""""""

PG Doc comments form <noreply@postgresql.org> writes:
> 11.9.2 lists ```SELECT x FROM tab WHERE x = 'key' AND z < 42;``` as both
> examples of 'could' and 'could not' use index-only scans.

No, look again: one of the queries uses the indexed column y,
and the other uses the non-indexed column z.

            regards, tom lane