Re: EXPLAIN IndexOnlyScan shows disabled when enable_indexonlyscan=on

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: EXPLAIN IndexOnlyScan shows disabled when enable_indexonlyscan=on
Date: 2024-10-22 19:21:06
Message-ID: CAApHDvrULZwq1A+86hSJfX0h1X+qX9J+w-U=hOFmuVQMBd4pVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 23 Oct 2024 at 02:08, Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
> However, it seems like there should be a way to force an index-only
> scan even if it is not the cheapest path. Perhaps I only think this as
> a developer needing to test something. But if enable_indexscan
> disables index-only scan then I don't see how I can force an
> index-only scan when it is not cheapest.

The way to do that is to turn off enable_seqscan and enable_bitmapscan
and ensure your query can support IOS.

The important part to remember here is that when creating the index
paths, the Index Only Scan is always assumed to be better than Index
Scan whenever it's possible to use IOS. There's no opportunity that if
an IOS is possible that you'll get an Index Scan instead. See
check_index_only() and build_index_paths() around where
check_index_only() is used.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2024-10-22 19:28:34 Re: EXPLAIN IndexOnlyScan shows disabled when enable_indexonlyscan=on
Previous Message Melanie Plageman 2024-10-22 19:12:53 Trigger more frequent autovacuums of heavy insert tables