On Sun, Nov 9, 2025 at 6:01 AM Tom Lane <[email protected]> wrote: > 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.
It looks like glibc's version is inlined, but others I checked aren't. > There are places where we wouldn't care about such microscopic > performance details, but I think syscache.c is not one of them. So we'd probably need our own inline function to keep the playing field level. Some tweaked algorithms[1] are also said to speed up small integer tables, Unicode tables etc. [1] https://github.com/scandum/binary_search
