| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: pg_upgrade's get_rel_infos_query() query can sometimes be slow |
| Date: | 2026-11-27 09:59:48 |
| Message-ID: | cfbe6462-232d-4fac-a5a5-8be5294d5885@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 27/11/2026 04:30, David Rowley wrote:
> I'm currently processing various internal reports about slow
> pg_upgrades. One of the points on the list is the
> get_rel_infos_query() is sometimes slow. The report said the query
> took 64.32 seconds for 100k tables. I was unable to get the EXPLAIN
> output.
>
> I was given the attached 03_get_rel_infos_100k_tables.sql script,
> which I suspect was AI-generated from a "reverse engineer this issue"
> type prompt as the script manually hacks reltuples and relpages to 1
> for pg_class, pg_index, and pg_namespace. I see no reason why those
> would ever be that low, but I understand that the stats can be
> outdated because autovacuum doesn't run on the target instance during
> the upgrade.
It seems bonkers to optimize for the case that the stats are bad like
that, reltuples=1 and relpages=1 is a completely unrealistic case. Even
if stats are missing, i.e. you haven't run vacuum, the default estimates
are not reltuples=1 and relpages=1. Initdb runs ANALYZE, so even if the
stats haven't been updated since, they would be a little better than that.
I think we'd need a little more realistic case to work with, before
making any changes.
- Heikki
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-11-27 10:29:24 | Re: pg_upgrade's get_rel_infos_query() query can sometimes be slow |
| Previous Message | Ayoub Kazar | 2026-11-27 09:57:42 | Re: Simplify the uniqueness proof for self-join elimination |