在唯一列上建立索引
Optimize 会识别唯一列上的冗余索引,并提供改进数据库性能的建议。
¥Optimize identifies redundant indexing on unique columns and provides recommendations for better database performance.
为什么这是一个问题
¥Why this is an issue
唯一性约束通过生成底层索引来固有地强制唯一性。在同一列上添加额外的索引是不必要的,并且会导致额外的开销。
¥Unique constraints inherently enforce uniqueness by generating an underlying index. Adding an additional index to the same column is unnecessary and can lead to extra overhead.
由于数据库必须同步多个索引,这种冗余会增加写入成本并降低更新速度。
¥This redundancy increases write costs and slows down updates, as the database must synchronize multiple indexes.
本指南也广泛应用于关系数据库,例如 PostgreSQL、MySQL、MariaDB、SQLite 和 SQL Server,这些数据库会自动为唯一约束创建索引。
¥This guideline also applies broadly to relational databases like PostgreSQL, MySQL, MariaDB, SQLite, and SQL Server, which automatically create indexes for unique constraints.