Re: BUG #18588: Cannot force/let database use parallel execution in simple case.

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Maxim Boguk <maxim.boguk@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2024-08-22T22:52:40Z
Lists: pgsql-bugs
David Rowley <dgrowleyml@gmail.com> writes:
> I played around with the attached script and set some breakpoints in
> cost_index(). I'm seeing the same thing as you with the parallel path
> being only slightly cheaper, but when looking at cost_index(), it's
> easy to see why.

> It's only the cpu_run_cost that's divided by the parallel_divisor.

D'oh.

What Maxim is observing is that he's getting I/O concurrency from
multiple workers; and that's an effect we're simply not accounting
for here.  cost_seqscan excuses the same omission with

         * It may be possible to amortize some of the I/O cost, but probably
         * not very much, because most operating systems already do aggressive
         * prefetching.  For now, we assume that the disk run cost can't be
         * amortized at all.

but I don't think this prefetch argument applies to index scans.

			regards, tom lane