From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Support SK_SEARCHNULL / SK_SEARCHNOTNULL for heap-only scans |
Date: | 2023-02-13 16:36:51 |
Message-ID: | 20230213163651.hicmmfqt2zka63dz@awork3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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)
> bool isnull;
> Datum test;
>
> - if (cur_key->sk_flags & SK_ISNULL)
> - return false;
> + if (cur_key->sk_flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL))
> + {
> + /* special case: looking for NULL / NOT NULL values */
> + Assert(cur_key->sk_flags & SK_ISNULL);
>
> - atp = heap_getattr(tuple, cur_key->sk_attno, tupdesc, &isnull);
> + atp = heap_getattr(tuple, cur_key->sk_attno, tupdesc, &isnull);
>
> - if (isnull)
> - return false;
> + if (isnull && (cur_key->sk_flags & SK_SEARCHNOTNULL))
> + return false;
>
> - test = FunctionCall2Coll(&cur_key->sk_func,
> - cur_key->sk_collation,
> - atp, cur_key->sk_argument);
> + if (!isnull && (cur_key->sk_flags & SK_SEARCHNULL))
> + return false;
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.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2023-02-13 16:46:59 | Re: run pgindent on a regular basis / scripted manner |
Previous Message | Drouvot, Bertrand | 2023-02-13 15:27:20 | Re: Minimal logical decoding on standbys |