Re: On disable_cost

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: On disable_cost
Date: 2024-07-04 01:29:39
Message-ID: CAApHDvrTWY+5TrDs4PDeRAMXdP+mE0QGFR5OiBjLB-oOLj9v8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 3 Jul 2024 at 09:49, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> > 3. Oh right, bitmap scan, I forgot about that one. Let's disable that too:
>
> Yeah, I've hit that too, although more often (for me) it's the first
> choice of plan. In any case, it usually takes more than one change
> to get to a seqscan.

I commonly hit this too.

I think the current behaviour is born out of the fact that we don't
produce both an Index Scan and an Index Only Scan for the same index.
We'll just make the IndexPath an index only scan, if possible based
on:

index_only_scan = (scantype != ST_BITMAPSCAN &&
check_index_only(rel, index));

The same isn't true for Bitmap Index Scans. We'll create both
IndexPaths and BitmapHeapPaths and let them battle it out in
add_path().

I suspect this is why it's been coded that enable_indexscan also
disables Index Only Scans. Now, of course, it could work another way,
but I also still think that doing so is changing well-established
behaviour that I don't recall anyone ever complaining about besides
Robert. Robert's complaint seems to have originated from something he
noticed while hacking on code rather than actually using the database
for something. I think the argument for changing it should have less
weight due to that.

I understand that we do have inconsistencies around this stuff. For
example, enable_sort has no influence on Incremental Sorts like
enable_indexscan has over Index Only Scan. That might come from the
fact that we used to, up until a couple of releases ago, produce both
sort path types and let them compete in add_path(). That's no longer
the case, we now just do incremental sort when we can, just like we do
Index Only Scans when we can. Despite those inconsistencies, I
wouldn't vote for changing either of them to align with the other. It
just feels too long-established behaviour to be messing with.

I feel it might be best to move this patch to the back of the series
or just drop it for now as it seems to be holding up the other stuff
from moving forward, and that stuff looks useful and worth changing.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-07-04 02:14:00 Re: Removing unneeded self joins
Previous Message Peter Smith 2024-07-04 01:09:42 Re: Logical Replication of sequences