Re: Use bsearch() instead of a manual binary search in syscache.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Antonin Houska <ah(at)cybertec(dot)at>, cca5507(at)qq(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Use bsearch() instead of a manual binary search in syscache.c
Date: 2025-11-08 17:01:26
Message-ID: 1469379.1762621286@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> One factor is that libc bsearch() implementations might not all be
> header-only and inlineable. I vaguely recall that being discussed in
> some round of hacking on qsort() and qunique().

I'm quite certain that years ago we determined that bsearch()
was slower than a manually written-out loop, probably because of
exactly the point that the comparisons would be inline. Don't
know whether modern compilers have changed that conclusion.

There are places where we wouldn't care about such microscopic
performance details, but I think syscache.c is not one of them.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-11-08 17:06:50 Re: pg_dump not dumping default_text_search_config WAI?
Previous Message Peter Eisentraut 2025-11-08 16:33:29 Re: MSVC: Improve warning options set