Yeah, I can't get excited about the cost of that for normal user dumps. The 002_pg_dump test does run a dump with --schema pg_catalog, but it's dubious that that test is worth its cycles.
Attached is the first optimization, which gets rid of the pg_class queries entirely, instead getting the same information from the existing queries in getTables and getIndexes.
Additionally, the string representation of the server version number is now stored in the Archive struct. Yes, we already have remoteVersion, but that's in integer form, and remoteVersionStr is "18devel" rather than "180000".
I didn't include any work on the attribute query as I wanted to keep that separate for clarity purposes.