Re: Preserve statistics targets with ALTER TABLE ALTER COLUMN TYPE

From: solai v <solai(dot)cdac(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Preserve statistics targets with ALTER TABLE ALTER COLUMN TYPE
Date: 2026-09-09 04:22:12
Message-ID: CAF0whuf+hNmKZ8xYGOCJ01a-QS39wwK2ob9N--X2OCYYLdF0Ew@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I reviewed and tested the patch.I was able to reproduce the reported
behavior on an unpatched PostgreSQL build. After creating an index and
generating index usage statistics (idx_scan > 0), executing ALTER
TABLE ... ALTER COLUMN ... TYPE caused the index statistics to be
reset.

Example:
Before ALTER TABLE:
test_b_idx | 1

After ALTER TABLE:
test_b_idx | 0

I then applied the v2 patch, rebuilt PostgreSQL, and repeated the same
test. With the patch applied, the index statistics were preserved
across ALTER TABLE TYPE.

Example:
Before ALTER TABLE:
test_b_idx | 1

After ALTER TABLE:
test_b_idx | 1

I also verified that the index continued to be used through an Index
Scan before and after the ALTER operation.Based on this testing, the
patch appears to address the reported issue and preserves the
historical index usage statistics during ALTER TABLE TYPE.

Regards,
Solai

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-09-09 04:23:55 Re: [PATCH] Release replication slot on error in SQL-callable slot functions
Previous Message Chao Li 2026-09-09 04:02:22 Re: pg_stat_progress_cluster: do not default to CLUSTER