Skip to content

Commit

Permalink
feat: add recommendation regarding blob type (#6554)
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 a630b4d commit b01d20c
Show file tree
Hide file tree
Showing 2 changed files with 31 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)
- [Storing large objects or BLOBs in the database](/optimize/recommendations/storing-blob-in-database)
- [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,30 @@
---
title: 'Storing large objects or BLOBs in the database'
metaTitle: 'Optimize recommendations: Avoid storing large objects or BLOBs in the database'
metaDescription: "Learn about the recommendations for avoiding the storage of large objects or BLOBs in the database."
tocDepth: 3
toc: true
---

Optimize provides recommendations to help identify and resolve performance issues caused by storing large objects in the database. It also suggests alternative approaches to mitigate these challenges.

The following model uses the `Bytes` type:

```prisma
model User {
id Int @id @default(autoincrement())
name String?
// Storing raw image data directly in the database
avatarBytes Bytes?
}
```

## What is the problem?

Storing large binary objects (such as images) in the database can lead to several challenges:

- **Excessive storage usage**: Large objects occupy significant space in the database, complicating management.
- **Increased I/O load**: Handling large objects adds strain to the database's input/output operations.
- **Slower query performance**: Most traditional databases are not optimized for efficiently serving large binary content, resulting in performance degradation during queries or updates.

Moreover, storing large objects directly in the database can cause backups to become disproportionately large, increasing the time required for restoration processes. Serving these files through the database also creates a performance bottleneck, particularly under high traffic or frequent access scenarios.

0 comments on commit b01d20c

Please sign in to comment.