-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into extra-indexing
- Loading branch information
Showing
18 changed files
with
3,152 additions
and
3,705 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
content/700-optimize/400-recommendations/1100-unnecessary-indexes.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,19 @@ | ||
--- | ||
title: 'Unnecessary indexes' | ||
metaTitle: 'Optimize Recommendations: Unnecessary indexes' | ||
metaDescription: "Learn about the recommendation provided by Optimize for using Unnecessary indexes" | ||
tocDepth: 3 | ||
toc: true | ||
--- | ||
|
||
Optimize detects unnecessary indexes and recommends removing them to improve database performance. | ||
|
||
### Why this is a problem | ||
|
||
Indexes enhance database query performance but can harm efficiency when overused. They consume storage and add overhead to `INSERT`, `UPDATE`, and `DELETE` operations. Unnecessary indexes can result in: | ||
|
||
- **Increased write costs:** Extra indexes slow down write operations. | ||
- **Higher storage use:** Unused indexes waste storage space. | ||
- **Query optimizer confusion:** Redundant indexes may cause inefficient query plans. | ||
|
||
Removing unnecessary indexes improves performance and simplifies maintenance. |
44 changes: 44 additions & 0 deletions
44
content/700-optimize/400-recommendations/1200-long-running-transactions.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,44 @@ | ||
--- | ||
title: 'Long-running transactions' | ||
metaTitle: 'Optimize Recommendations: Avoid long-running transactions' | ||
metaDescription: "Learn about the recommendation provided by Optimize for long-running transaction." | ||
tocDepth: 3 | ||
toc: true | ||
--- | ||
|
||
Optimize provides actionable recommendations to help you identify and resolve performance issues caused by **long-running transactions**. | ||
|
||
**Long-running transactions** can negatively impact scalability and resilience by locking resources and holding database connections for extended periods. Below is a common example of a problematic long-running transaction: | ||
|
||
```ts | ||
// Example: A single massive transaction performing multiple steps | ||
await prisma.$transaction(async (prisma) => { | ||
const order = await prisma.order.create({ | ||
data: { | ||
/* ... */ | ||
}, | ||
}); | ||
await prisma.user.update({ | ||
where: { id: userId }, | ||
data: { balance: { decrement: order.total } }, | ||
}); | ||
await prisma.shipping.create({ data: { orderId: order.id /* ... */ } }); | ||
// Additional dependent operations | ||
}); | ||
``` | ||
|
||
### What is the problem? | ||
|
||
Long-running transactions can cause several critical issues that harm the performance and reliability of your application: | ||
|
||
- **Database locks**: Long transactions hold locks on rows, tables, or other resources, preventing access by other queries. This leads to contention and blocking, which can significantly disrupt concurrent operations. | ||
|
||
- **Connection tie-ups**: Transactions occupy database connections for their entire duration. With a limited connection pool, this can quickly exhaust available connections, resulting in application-wide slowdowns or failures. | ||
|
||
- **Increased contention**: As locks accumulate and connections are tied up, other transactions queue up, creating bottlenecks, higher latency, and reduced throughput. | ||
|
||
- **Scalability challenges**: Inefficiencies caused by long transactions are magnified in high-traffic systems, limiting the system’s ability to scale effectively. | ||
|
||
- **Fragility**: When a long transaction fails or times out, all intermediate progress is lost. This is especially problematic in workflows with multiple dependent steps, as recovering from partial failures becomes complex and error-prone. | ||
|
||
- **Debugging difficulties**: Troubleshooting long-running transactions is challenging due to their multiple steps and potential failures caused by timeouts, deadlocks, or unexpected dependencies. |
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
2 changes: 1 addition & 1 deletion
2
content/800-guides/300-data-migration-with-expand-and-contract.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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.