Re: Many of psql's describe functions bloat cache / waste mem

From: xliu19163(at)gmail(dot)com
To: Jan Nidzwetzki <jan(at)planetscale(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Many of psql's describe functions bloat cache / waste mem
Date: 2026-09-01 03:00:35
Message-ID: CAPPb3yj76D+s+1E1LS=VHynrjKnRypjxrkDM2WP9OXW7aB+p-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jan,

Thanks for the detailed review and for confirming the memory reduction.

Attached is v2. I followed your suggestions:

- introduced appendSystemSchemaFilter() and reused it in the
describe.c queries that exclude pg_catalog and information_schema,
including \df and \do;
- changed the corresponding object-to-pg_namespace LEFT JOINs to JOIN
where the namespace is mandatory;
- removed the TAP test from v1, since checking the generated SQL text
cannot guarantee planner clause evaluation order.

The filter still uses an uncorrelated pg_namespace subquery, so it
becomes an InitPlan. The ARRAY(...) / <> ALL form also continues to
work when information_schema is absent.

I rebased v2 onto current master (3b120b1e94d). make check-world
passes for all suites enabled in my local build. TAP tests were not
enabled because IPC::Run is not available locally. I also manually
checked the affected psql commands, including \df and \do, and
confirmed the expected plan shape and CacheMemoryContext behavior.

Please let me know what you think.

Best regards,
Xiaoyu

Attachment Content-Type Size
v2-0001-psql-filter-system-objects-before-visibility-chec.patch text/x-patch 15.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-09-01 03:15:00 Re: pg_xmin_horizon: a system view of everything pinning the xmin horizon
Previous Message Fujii Masao 2026-09-01 02:48:59 Re: Failing assertion while taking a restartpoint during crash recovery