Re: Qual push down to table AM

From: Julien Tachoires <julien(at)tachoires(dot)me>
To: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Qual push down to table AM
Date: 2025-12-02 13:09:01
Message-ID: 20251202130901.olusqddnna3oqzxa@poseidon.home.virt
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Mark,

On Tue, Oct 07, 2025 at 04:55:53PM -0700, Mark Dilger wrote:
> v1-0001:
> All current callers of scan_rescan() pass NULL for the `key` parameter,
> making it unclear to
> Table AM authors if this is supposed to be a pointer to a single key, or
> an array. If an array,
> how is it terminated? None of this is addressed in the current code
> comments, and given
> that nobody uses this field, the intent is undiscoverable. By adding
> `int nkeys` to the parameter
> list, your patch makes the intention clearer. Perhaps you could also
> update the documentation
> for these functions?
>
> v1-0002
> Changing the EXPLAIN output to include where the exclusion happened is
> quite nice!
>
> Out of curiosity, why did you wait until this patch to add the `int
> nkeys` parameter to
> initscan()? It seems more on-topic for v1-0001. Likewise, renaming
> `key` as `keys` helps,
> but could have been done in v1-0001.

Thanks for your review. Please find a new version attached that addresses
these points.

> As for Andres' concern upstream, I am including a Work-In-Progress patch
> (WIP) to check
> that no light-weight locks are held during qual evaluation. I don't intend
> this for commit so much
> as for discussion. It seems to me fairly clear that your patch does not
> evaluate the quals while
> holding such locks, but I might have misunderstood the concern.

Thanks, it helps to confirm that due to the absence of ScanKey,
HeapKeyTest() is not called from heapgettup(), at least when running the
regression tests.

In order to guarantee to not hold the Buffer lock while evaluating a
ScanKey, v4-0001-Release-buffer-lock-before-scan-key-evaluation releases
the lock before calling HeapKeyTest().

Regards,

--
Julien Tachoires

Attachment Content-Type Size
v4-0001-Release-buffer-lock-before-scan-key-evaluation.patch text/x-diff 1.7 KB
v4-0002-Pass-the-number-of-ScanKeys-to-scan_rescan.patch text/x-diff 17.4 KB
v4-0003-Simple-quals-push-down-to-table-AMs.patch text/x-diff 54.8 KB
v4-0004-Add-the-table-reloption-quals_push_down.patch text/x-diff 11.5 KB
v4-0005-Add-tests-for-quals-push-down-to-table-AM.patch text/x-diff 13.1 KB
v4-0006-Push-down-IN-NOT-IN-array-quals-to-table-AMs.patch text/x-diff 30.8 KB
v4-0007-Push-down-IS-IS-NOT-NULL-quals-to-table-AMs.patch text/x-diff 22.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message tushar 2025-12-02 13:15:06 Re: Non-text mode for pg_dumpall
Previous Message Álvaro Herrera 2025-12-02 13:07:47 Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY