-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add optimize recommendaion, avoid char (#6531)
* feat: add optimize recommendaion, avoid char * chore: add n * Update content/700-optimize/400-recommendations/700-avoid-char.mdx * Update content/700-optimize/400-recommendations/700-avoid-char.mdx * Apply suggestions from code review --------- Co-authored-by: Jon Harrell <4829245+jharrell@users.noreply.github.com>
- Loading branch information
1 parent
cf2f44e
commit 38b134e
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
21 changes: 21 additions & 0 deletions
21
content/700-optimize/400-recommendations/700-avoid-char.mdx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: 'Using @db.Char(n)' | ||
metaTitle: 'Optimize Recommendations: Avoid usage of `@db.Char(n)`' | ||
metaDescription: "Learn about the recommendation provided by Optimize for using `@db.Char(n)` native type." | ||
--- | ||
|
||
Optimize provides recommendations to help you identify and resolve performance issues caused by the use of `@db.Char(n)` type in PostgreSQL. | ||
|
||
In the following example, the `@db.Char(n)` native type has been used within the `Item` model on the `name` field: | ||
|
||
```prisma | ||
model Item { | ||
// ... | ||
name String @db.Char(1) | ||
// ... | ||
} | ||
``` | ||
|
||
### Why this is a problem | ||
|
||
The `@db.Char(n)` type enforces a fixed length of `n`, which can cause unexpected issues in production if not properly managed by the application. In PostgreSQL, `char(n)` pads shorter values with spaces, leading to problems during comparisons and other operations. Unlike some databases that optimize `char(n)`, PostgreSQL does not offer such optimizations, making careful handling essential. |