Original query:

explain analyze
SELECT "main"."oid" "oid", "main"."name" "name", (COALESCE("fields"."fields", 0)) "fields", (COALESCE("ind"."indexes", 0)) "indexes", (COALESCE("constraints"."constraints", 0) + COALESCE("constraints2"."constraints", 0)) "constraints", "main"."rows" "rows", (((("main"."relpages" + (CASE "main"."reltoastrelid" WHEN 0 THEN 0 ELSE COALESCE((SELECT SUM("relpages") FROM "pg_class" "toa" WHERE "oid" = "main"."reltoastrelid"), 0) + COALESCE((SELECT SUM("relpages") FROM "pg_class" "toa" WHERE "oid" IN (SELECT "indexrelid" FROM "pg_index" WHERE "indrelid" = "main"."reltoastrelid")), 0) END))) + COALESCE("ind"."relpages", 0)) * 8192) "size", "main"."datasize" "datasize", "main"."seqscans" "seqscans", "main"."idxscans" "idxscans", "main"."idxscanrate" "idxscanrate", "main"."hotrate" "hotrate", "main"."deadrate" "deadrate", "main"."relpages" "relpages", "main"."reltoastrelid" "reltoastrelid"
FROM (SELECT "main"."oid" "oid", "main"."relname" "name", ("main"."reltuples"::bigint) "rows", ("main"."relpages" * 8192) "datasize", "sta"."seq_scan" "seqscans", (COALESCE("sta"."idx_scan", 0)) "idxscans", (COALESCE(("sta"."idx_scan" * 100 / ("sta"."seq_scan" + "sta"."idx_scan" + 0.000001)), 0)) "idxscanrate", (CASE WHEN "sta"."n_tup_upd" <> 0 THEN "sta"."n_tup_hot_upd" * 100 / "sta"."n_tup_upd" END) "hotrate", ("sta"."n_dead_tup" * 100 / ("sta"."n_dead_tup" + "main"."reltuples" + 0.000001)) "deadrate", "main"."relpages" "relpages", "main"."reltoastrelid" "reltoastrelid"
FROM "pg_class" "main"
INNER JOIN "pg_stat_all_tables" "sta" ON "sta"."relid" = "main"."oid"
WHERE ("main"."relnamespace" = (CURRENT_SCHEMA()::regnamespace) AND "main"."relkind" = 'r' AND "sta"."schemaname" = (CURRENT_SCHEMA()))
ORDER BY "main"."relname", "main"."oid"
LIMIT 100) "main"
LEFT JOIN (SELECT (COUNT(*)) "indexes", (SUM("cls"."relpages")) "relpages", "ind"."indrelid" "ID"
FROM "pg_index" "ind"
INNER JOIN "pg_class" "cls" ON "cls"."oid" = "ind"."indexrelid"
WHERE "cls"."relnamespace" = (CURRENT_SCHEMA()::regnamespace)
GROUP BY "ind"."indrelid") "ind" ON "ind"."ID" = "main"."oid"
LEFT JOIN (SELECT (COUNT(*)) "fields", "attrelid" "ID"
FROM "pg_attribute" "att"
WHERE ("att"."attrelid" IN (SELECT "oid" FROM "pg_class" WHERE "relnamespace" = (CURRENT_SCHEMA()::regnamespace)) AND "att"."attnum" > 0 AND NOT "att"."attisdropped")
GROUP BY "attrelid") "fields" ON "fields"."ID" = "main"."oid"
LEFT JOIN LATERAL (SELECT (COUNT(*)) "constraints"
FROM "pg_constraint" "con"
WHERE "conrelid" = "main"."oid") "constraints" ON TRUE
LEFT JOIN LATERAL (SELECT (COUNT(*)) "constraints"
FROM "pg_constraint" "con"
WHERE "contypid" IN (SELECT "atttypid" FROM "pg_attribute" WHERE ("attrelid" = "main"."oid" AND "attnum" > 0 AND NOT "attisdropped"))) "constraints2" ON TRUE
ORDER BY "main"."name", "main"."oid"