Re: pg_plan_advice

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Lukas Fittl <lukas(at)fittl(dot)com>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, Dian Fay <di(at)nmfay(dot)com>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_plan_advice
Date: 2026-01-13 11:38:51
Message-ID: CANWCAZZgKnf8dNOd_w03n88NqOfmMnMv2=D8_Oy6ADGyiMq+cg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 13, 2026 at 12:14 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Here's v9. Changes:

This is perhaps the least interesting part of 0005, but since I
committed this API, I thought I'd chime in:

+ /* alias_name may not be NULL */
+ sp_len = fasthash_accum_cstring(&hs, key.alias_name);
+
+ /* partition_name and plan_name, however, can be NULL */
+ if (key.partition_name != NULL)
+ sp_len += fasthash_accum_cstring(&hs, key.partition_name);
+ if (key.plan_name != NULL)
+ sp_len += fasthash_accum_cstring(&hs, key.plan_name);

It looks like it would be helpful if fasthash_accum_cstring just
returned zero when given a NULL string, as in the attached. We could
also do something like add a large number to the hash, but I'm not
sure that's necessary.

+ /*
+ * hashfn_unstable.h recommends using string length as tweak. It's not
+ * clear to me what to do if there are multiple strings, so for now I'm
+ * just using the total of all of the lengths.
+ */
+ return fasthash_final32(&hs, sp_len);

Sounds reasonable, so the patch also documents that.

--
John Naylor
Amazon Web Services

Attachment Content-Type Size
fasthash-zero-len.patch.nocfbot application/octet-stream 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-01-13 11:54:03 Re: [PATCH} Move instrumentation structs
Previous Message Álvaro Herrera 2026-01-13 11:38:39 Re: [PATCH} Move instrumentation structs