Skip to content

Commit

Permalink
feat: add recommendation on indexes in unique columns (#6553)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Harrell <[email protected]>
  • Loading branch information
ankur-arch and jharrell authored Jan 9, 2025
1 parent 41c4602 commit a630b4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions content/700-optimize/300-recordings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit a630b4d

Please sign in to comment.