Re: check for null value before looking up the hash function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: peter(at)eisentraut(dot)org, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: check for null value before looking up the hash function
Date: 2022-05-20 20:33:02
Message-ID: 487989.1653078782@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zhihong Yu <zyu(at)yugabyte(dot)com> writes:
> I was looking at the code in hash_record()
> of src/backend/utils/adt/rowtypes.c
> It seems if nulls[i] is true, we don't need to look up the hash function.

I don't think this is worth changing. It complicates the logic,
rendering it unlike quite a few other functions written in the same
style. In cases where the performance actually matters, the hash
function is cached across multiple calls anyway. You might save
something if you have many calls in a query and not one of them
receives a non-null input, but how likely is that?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-05-20 20:39:29 Re: CPU time for pg_stat_statement
Previous Message Stephen Frost 2022-05-20 20:17:42 Re: Zstandard support for toast compression