Re: Improving scalability of Parallel Bitmap Heap/Index Scan

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: David Geier <geidav(dot)pg(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improving scalability of Parallel Bitmap Heap/Index Scan
Date: 2026-10-14 07:16:04
Message-ID: CANWCAZaRoe7mBUFNNyXJ61O3Ag2KT02yt2g3RYOwa_zkEJFH_g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 14, 2026 at 5:27 AM David Geier <geidav(dot)pg(at)gmail(dot)com> wrote:
> > If that's the case, let's get that piece in committable shape first.
> > That will make sure PG20 gets some improvement regardless of what
> > happens with your other proposal, and allows us to isolate the effect
> > of the proposed architectural change.
> Attached is the patch for using sort_template.h in TIDBitmap based on
> master. No other parallel BIS changes.

+/* Needed for sort template to work with pointers to PagetableEntry */
+typedef PagetableEntry *PagetableEntryPtr;

This is a workaround; let's fix it properly, like this:

ST_POINTER_TYPE *a = (ST_POINTER_TYPE *) data;
ST_POINTER_TYPE *pa;
ST_POINTER_TYPE *pb;
...

I see that Thomas already encountered that problem in the 0001 patch
of that series:

https://www.postgresql.org/message-id/attachment/120554/0001-Add-bsearch-and-unique-templates-to-sort_template.h.patch

+#define ST_COMPARE(a, b) pg_cmp_u32((*(a))->blockno, (*(b))->blockno)
...
+#define ST_COMPARE(a, b, base) pg_cmp_u32(base[*(a)].blockno,
base[*(b)].blockno)

There's a comment in common/int.h that says:

* NB: If the comparator function is inlined, some compilers may produce
* worse code with these helper functions than with code with the
* following form:
*
* if (a < b)
* return -1;
* if (a > b)
* return 1;
* return 0;

...and that's been true every time it's tried. It should be fine to
instead make the current comparators static inline and make both match
the above pattern. You might get a further speed-up.

--
John Naylor
Amazon Web Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-10-14 07:17:44 Re: pg_upgrade fails with a config-only datadir and no --new-bindir
Previous Message Zhijie Hou 2026-10-14 07:16:01 Re: Bug in logical decoding with DDL and subtransactions