Experimenting with hash tables inside pg_dump
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2021-10-21T22:27:25Z
Lists: pgsql-hackers
Attachments
- use-simplehash-in-pg-dump-1.patch (text/x-diff) patch
Today, pg_dump does a lot of internal lookups via binary search in presorted arrays. I thought it might improve matters to replace those binary searches with hash tables, theoretically converting O(log N) searches into O(1) searches. So I tried making a hash table indexed by CatalogId (tableoid+oid) with simplehash.h, and replacing as many data structures as I could with that. This makes the code shorter and (IMO anyway) cleaner, but (a) the executable size increases by a few KB --- apparently, even the minimum subset of simplehash.h's functionality is code-wasteful. (b) I couldn't measure any change in performance at all. I tried it on the regression database and on a toy DB with 10000 simple tables. Maybe on a really large DB you'd notice some difference, but I'm not very optimistic now. So this experiment feels like a failure, but I thought I'd post the patch and results for the archives' sake. Maybe somebody will think of a way to improve matters. Or maybe it's worth doing just to shorten the code? regards, tom lane
Commits
-
In pg_dump, use simplehash.h to look up dumpable objects by OID.
- 92316a4582a5 15.0 landed
-
Fix frontend version of sh_error() in simplehash.h.
- 974aedcea46d 15.0 landed
- 8cee4be6dc93 14.1 landed
- 2e01d050d989 13.5 landed