[PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-02-13 Thread Aleksander Alekseev
Hi hackers, A colleague of mine wanted to use a ScanKey with SK_SEARCHNULL flag for a heap-only scan (besides other ScanKeys) and discovered that the result differs from what he would expect. Turned out that this is currently not supported as it is explicitly stated in skey.h. Although several wo

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-02-13 Thread Andres Freund
Hi, On 2023-02-13 17:59:13 +0300, Aleksander Alekseev wrote: > @@ -36,20 +36,36 @@ HeapKeyTest(HeapTuple tuple, TupleDesc tupdesc, int > nkeys, ScanKey keys) > boolisnull; > Datum test; > > - if (cur_key->sk_flags & SK_ISNULL) > -

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-02-14 Thread Aleksander Alekseev
Hi Andres, > Shouldn't need to extract the column if we just want to know if it's NULL (see > heap_attisnull()). Afaics the value isn't accessed after this. Many thanks. Fixed. -- Best regards, Aleksander Alekseev v2-0001-Support-SK_SEARCHNULL-SK_SEARCHNOTNULL-for-heap-o.patch Description: Bi

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-02-22 Thread Heikki Linnakangas
On 14/02/2023 11:10, Aleksander Alekseev wrote: Hi Andres, Shouldn't need to extract the column if we just want to know if it's NULL (see heap_attisnull()). Afaics the value isn't accessed after this. Many thanks. Fixed. I'm confused, what exactly is the benefit of this? What extension per

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-02-22 Thread Aleksander Alekseev
Hi, > I'm confused, what exactly is the benefit of this? What extension > performs a direct table scan bypassing the executor, searching for NULLs > or not-NULLs? Basically any extension that accesses the tables without SPI in order to avoid parsing and planning overhead for relatively simple cas

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-02-27 Thread Heikki Linnakangas
On 22/02/2023 15:03, Aleksander Alekseev wrote: Additionally, practice shows that for an extension author it's very easy to miss a comment in skey.h: """ * SK_SEARCHARRAY, SK_SEARCHNULL and SK_SEARCHNOTNULL are supported only * for index scans, not heap scans; """ ... which results in many

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-08-30 Thread Jacob Champion
On 7/19/23 16:44, Jacob Champion wrote: > This patch pushes down any > forced-null and not-null Vars as ScanKeys. It doesn't remove the > redundant quals after turning them into ScanKeys, so it's needlessly > inefficient, but there's still a decent speedup for some of the basic > benchmarks in 0003

Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans

2023-07-19 Thread Jacob Champion
On Mon, Feb 27, 2023 at 12:24 AM Heikki Linnakangas wrote: > On 22/02/2023 15:03, Aleksander Alekseev wrote: > > If memory serves I noticed that WHERE ... IS NULL queries don't even > > hit HeapKeyTest() and I was curious where the check for NULLs is > > actually made. As I understand, SeqNext() i