Re: Use bsearch() instead of a manual binary search in syscache.c
cca5507 <cca5507@qq.com>
From: cca5507 <cca5507@qq.com>
To: Thomas Munro <thomas.munro@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Antonin Houska <ah@cybertec.at>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-09T07:50:29Z
Lists: pgsql-hackers
Hi, Thanks for the explanation which helps me a lot! The bsearch() got inlined according to compiler explorer: https://godbolt.org/z/1x69zGMcn 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. How about add a pg_bsearch() and #define bsearch(a,b,c,d,e) pg_bsearch(a,b,c,d,e) to use it? -- Regards, ChangAo Chen