perf(db): drop redundant single-column indexes#2893
Open
ZeroClover wants to merge 1 commit into
Open
Conversation
Contributor
|
All contributors have signed the CLA. ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
云数据库巡检标记的 13 个单列索引,其列均为既有复合/唯一索引的最左前缀, PostgreSQL 可用更宽的索引服务相同查询,单列索引纯属冗余,只增加写放大与存储。 - 新增迁移 143_drop_redundant_indexes_notx.sql:以 DROP INDEX CONCURRENTLY IF EXISTS 删除全部 13 个索引(usage_logs×6、两张 dashboard 去重表、 payment_audit_logs、channel_monitors、auth_identities、 auth_identity_migration_reports、user_provider_default_grants), 非事务幂等执行,避免在高写入的 usage_logs 上持有排他锁。 - 同步移除 ent schema 中对应的 9 个单列索引声明并重新生成 ent 代码; 保留 usage_logs.group_id(线上为 group_id IS NOT NULL 的部分复合索引, 无法覆盖 NULL,未被标记为冗余)。 - 修正迁移校验器以首关键字判定 CREATE/DROP,避免名称含 "created" 的 索引(如 idx_usage_logs_created_at)被误判为 CREATE 而要求 IF NOT EXISTS; 补充对应回归用例。
043fdb2 to
0e73692
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
云数据库巡检标记的 13 个单列索引,其列均为既有复合/唯一索引的最左前缀,
PostgreSQL 可用更宽的索引服务相同查询,单列索引纯属冗余,只增加写放大与存储。