Re: Improving scalability of Parallel Bitmap Heap/Index Scan

From: David Geier <geidav(dot)pg(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: John Naylor <johncnaylorls(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improving scalability of Parallel Bitmap Heap/Index Scan
Date: 2026-10-16 07:55:36
Message-ID: f74159a3-3ba7-4a11-941a-21cf9199603a@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Shihao,

Thanks for your review.

> 1. With ST_COMPARE_RUNTIME_POINTER the typedef
> uses const ST_ELEMENT_TYPE *, which for Item * becomes const Item **,
> so a comparator taking Item *const * warns. ST_ELEMENT_TYPE const *
> fixes it.
>
> 2. tbm_comparator() lost its const. It can take
> PagetableEntry *const *.

This makes it a const pointer to a pointer to a PagetableEntry. So the
PagetableEntry can still be modified through the pointer. The main use
of consting the pointer arguments is guaranteeing the compiler that the
function doesn't modify them. FWICS, this is not the case with what you
propose.

We would need const PagetableEntry *const *lpage but with that
compilation fails because sort_template.h wants to pass PagetableEntry
** which cannot be converted implicitly.

What I ended up doing is dereferencing the double pointer here:

#define ST_COMPARE(a, b) tbm_comparator(*(a), *(b))

Now we can use tbm_comparator(const PagetableEntry *lpage, ...). This
way we can also call tbm_comparator() from tbm_comparator_shared() which
is neat.

> 3. The common/int.h include in tidbitmap.c is now unused.

Done.

> 4. tbm_shared_comparator() is missing inline in its definition.

Done.

Attached is patch set v3.

--
David Geier

Attachment Content-Type Size
v3-0002-TIDBitmap-uses-sort_template.h-for-pagetable-sort.patch text/x-patch 4.9 KB
v3-0001-sort_template.h-supports-pointer-element-types.patch text/x-patch 1.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Bertrand Drouvot 2026-10-16 07:53:43 Re: ALTER TABLE uses a bistate but not for toast tables