Re: CREATE INDEX vs. TOAST table stats

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql(at)j-davis(dot)com
Subject: Re: CREATE INDEX vs. TOAST table stats
Date: 2026-08-11 19:25:10
Message-ID: CAA5RZ0v0xgNOKNaN0AJwZm9c_rn9s=KSaA2h+Nq69DPXCxkgig@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I agree on removing RELKIND_TOASTVALUE. A toast table has no restorable stats,
so we should not attempt to preserve the stats here. Also, main
relation and toast
drifting in stats already happens. We are not introducing any issue
here, AFAICT.

> if (rel->rd_rel->relkind == RELKIND_RELATION ||
> - rel->rd_rel->relkind == RELKIND_TOASTVALUE ||
> rel->rd_rel->relkind == RELKIND_MATVIEW)

One thing is CREATE INDEX, mentioned in the subject, never calls
index_update_stats()
on the toast relation, so the toast stats are not updated by it. This
will only be called when
the toast's own index is rebuilt, i.e. REINDEX, VACUUM FULL, CLUSTER, REPACK.

+1 on backpatching to v18.

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexandre Felipe 2026-08-11 19:32:40 Re: [PATCH] bufmgr: tighten LWLock:BufferMapping on InvalidateBuffer
Previous Message Jeff Davis 2026-08-11 19:20:31 Re: Crash issue in PG18.5 regression