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
