Re: Preserve index stats during ALTER TABLE ... TYPE ... - Mailing list pgsql-hackers

From solai v
Subject Re: Preserve index stats during ALTER TABLE ... TYPE ...
Date
Msg-id CAF0whucLNV_aGw-1YBnJt7_SGOmRAXnb2SeiMSYDUenpxpv4aQ@mail.gmail.com
Whole thread
In response to Re: Preserve index stats during ALTER TABLE ... TYPE ...  (Michael Paquier <michael@paquier.xyz>)
List 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



pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: IGNORE/RESPECT NULLS can be specified for (prokind == 'f').
Next
From: Pavel Stehule
Date:
Subject: Re: proposal - queryid can be used as filter for auto_explain