diff --git a/content/700-optimize/300-recordings.mdx b/content/700-optimize/300-recordings.mdx index 7497a9d5e5..71f84f56b9 100644 --- a/content/700-optimize/300-recordings.mdx +++ b/content/700-optimize/300-recordings.mdx @@ -45,6 +45,7 @@ When a recording session ends, Optimize generates recommendations such as: - [Using `@db.Char(n)`](/optimize/recommendations/avoid-char) - [Using `@db.VarChar(n)`](/optimize/recommendations/avoid-varchar) - [Using `timestamp(0)` or `timestamptz(0)`](/optimize/recommendations/avoid-timestamp-timestampz-0) +- [Indexing on unique columns](/optimize/recommendations/indexing-on-unique-columns) - [Long-running transactions](/optimize/recommendations/long-running-transactions) - [Unnecessary indexes](/optimize/recommendations/unnecessary-indexes) diff --git a/content/700-optimize/400-recommendations/1300-indexing-on-unique-columns.mdx b/content/700-optimize/400-recommendations/1300-indexing-on-unique-columns.mdx new file mode 100644 index 0000000000..dea66ea352 --- /dev/null +++ b/content/700-optimize/400-recommendations/1300-indexing-on-unique-columns.mdx @@ -0,0 +1,17 @@ +--- +title: 'Indexing on unique columns' +metaTitle: 'Optimize recommendations: Indexing on unique columns' +metaDescription: "Learn about the recommendation provided by Optimize regarding indexing on uniquely constrained columns." +tocDepth: 3 +toc: true +--- + +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. + +This guideline applies broadly to relational databases like PostgreSQL, MySQL, MariaDB, SQLite, and SQL Server, which automatically create indexes for unique constraints.