Skip to content

Commit

Permalink
Merge branch 'main' into extra-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
jharrell authored Jan 9, 2025
2 parents 46e5833 + 41c4602 commit 80029e2
Show file tree
Hide file tree
Showing 18 changed files with 3,152 additions and 3,705 deletions.
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

2 changes: 2 additions & 0 deletions content/700-optimize/300-recordings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ When a recording session ends, Optimize generates recommendations such as:
- [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)

:::info
Use [Prisma AI](/optimize/prisma-ai) to ask follow-up questions about a recommendation.
Expand Down
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.
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.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'Using Prisma with Turborepo'
metaTitle: 'Using Prisma with Turborepo'
metaDescription: 'Learn step-by-step how to integrate Prisma ORM with Turborepo to build modular, scalable monorepo architectures efficiently.'
description: 'Learn step-by-step how to integrate Prisma ORM with Turborepo to build modular, scalable monorepo architectures efficiently.'
sidebar_label: 'Prisma with Turborepo'
image: '/img/guides/prisma-turborepo-setup.png'
tags:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to migrate data using the expand and contract pattern'
metaTitle: 'How to migrate data using the expand and contract pattern'
metaDescription: 'Learn how to perform data migrations using the expand and contract pattern with Prisma ORM'
description: 'Learn how to perform data migrations using the expand and contract pattern with Prisma ORM'
sidebar_label: 'Data migration with expand and contract'
image: '/img/guides/data-migration-cover.png'
tags:
Expand Down
2 changes: 1 addition & 1 deletion content/800-guides/400-implementing-schema-changes.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to manage schema changes in a team'
metaTitle: 'How to manage schema changes in a team with Prisma Migrate'
metaDescription: 'Learn how to use Prisma Migrate effectively when collaborating on a project as a team'
description: 'Learn how to use Prisma Migrate effectively when collaborating on a project as a team'
sidebar_label: 'Team schema changes'
image: '/img/guides/schema-migration-cover.png'
---
Expand Down
4 changes: 1 addition & 3 deletions content/800-guides/500-migrate-from-typeorm.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
title: 'How to migrate from TypeORM to Prisma ORM'
metaTitle: 'How to migrate from TypeORM to Prisma ORM'
metaDescription: 'Learn how to migrate from TypeORM to Prisma ORM'
description: 'Learn how to migrate from TypeORM to Prisma ORM'
sidebar_label: 'Migrate from TypeORM'
image: '/img/guides/migrate-from-typeorm-cover.png'
---

# How to migrate from TypeORM to Prisma ORM

## Introduction

This guide shows you how to migrate your application from TypeORM to Prisma ORM. We'll use an extended version of the [TypeORM Express example](https://github.com/typeorm/typescript-express-example/) as a [sample project](https://github.com/prisma/migrate-from-typeorm-to-prisma) to demonstrate the migration steps.
Expand Down
8 changes: 4 additions & 4 deletions content/800-guides/5000-guide-on-making-guides.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to write guides for Prisma ORM'
metaTitle: 'How to write guides for Prisma ORM'
metaDescription: 'Learn how to write clear, consistent, and helpful guides for Prisma ORM documentation'
description: 'Learn how to write clear, consistent, and helpful guides for Prisma ORM documentation'
sidebar_label: 'Guide writing guide'
image: '/img/guides/guide-writing-guide-cover.png'
---
Expand Down Expand Up @@ -29,15 +29,15 @@ Every guide must include the following frontmatter at the top of the file:
---
title: 'How to [do something] with Prisma ORM'
metaTitle: 'How to [do something] with Prisma ORM'
metaDescription: 'Learn how to [do something] with Prisma ORM'
description: 'Learn how to [do something] with Prisma ORM'
sidebar_label: '[Concise Label]'
image: '/img/guides/[guide-name]-cover.png'
---
```

- `title`: Should be action-oriented and start with "How to"
- `metaTitle`: Usually matches the title
- `metaDescription`: A one-sentence summary starting with "Learn how to"
- `metaTitle`: Usually matches the title, used for SEO
- `description`: A one-sentence summary starting with "Learn how to", used for SEO
- `sidebar_label`: A concise label for the sidebar navigation
- `image`: A unique header image for social media sharing (coordinate with the design team)

Expand Down
2 changes: 1 addition & 1 deletion content/800-guides/600-migrate-from-sequelize.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to migrate from Sequelize to Prisma ORM'
metaTitle: 'How to migrate from Sequelize to Prisma ORM'
metaDescription: 'Learn how to migrate from Sequelize to Prisma ORM'
description: 'Learn how to migrate from Sequelize to Prisma ORM'
sidebar_label: 'Migrate from Sequelize'
image: '/img/guides/migrate-from-sequelize-cover.png'
---
Expand Down
2 changes: 1 addition & 1 deletion content/800-guides/700-migrate-from-mongoose.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to migrate from Mongoose to Prisma ORM'
metaTitle: 'How to migrate from Mongoose to Prisma ORM'
metaDescription: 'Learn how to migrate from Mongoose to Prisma ORM'
description: 'Learn how to migrate from Mongoose to Prisma ORM'
sidebar_label: 'Migrate from Mongoose'
image: '/img/guides/migrate-from-mongoose-cover.png'
---
Expand Down
2 changes: 1 addition & 1 deletion content/800-guides/800-migrate-from-drizzle.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to migrate from Drizzle to Prisma ORM'
metaTitle: 'How to migrate from Drizzle to Prisma ORM'
metaDescription: 'Learn how to migrate from Drizzle to Prisma ORM'
description: 'Learn how to migrate from Drizzle to Prisma ORM'
sidebar_label: 'Migrate from Drizzle'
image: '/img/guides/migrate-from-drizzle-cover.png'
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'How to use Prisma ORM with Cloudflare D1'
metaTitle: 'How to use Prisma ORM with Cloudflare D1'
metaDescription: 'Learn how to use Prisma ORM with Cloudflare D1'
description: 'Learn how to use Prisma ORM with Cloudflare D1'
sidebar_label: 'Use with Cloudflare D1'
image: '/img/guides/prisma-d1-setup-cover.png'
---
Expand Down
5 changes: 3 additions & 2 deletions content/800-guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metaTitle: 'Prisma Guides'
metaDescription: 'A collection of guides for various tasks and workflows.'
sidebar_label: 'Guides'
sidebar_position: 0
image: '/img/guides/guides-index-cover.png'
tags:
- guides
- tutorials
Expand All @@ -16,9 +17,9 @@ tags:
- best-practices
---

# Guides
Welcome to the Guides section! Here you'll find practical, step-by-step guides to help you accomplish specific tasks with Prisma products, including Prisma ORM, Prisma Accelerate, Prisma Pulse, and more.

Welcome to the Guides section! Here you will find various guides to help you with different tasks and workflows. Learn how to include Prisma ORM in your project, or integrate Prisma ORM with various services and libraries.
Browse through our guides below or use the search to find specific topics.

## Available Guides

Expand Down
7 changes: 5 additions & 2 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { themes as prismThemes } from "prism-react-renderer";

const path = require('path')
import path from "path";

import type { Config } from "@docusaurus/types";
import type * as Preset from "@docusaurus/preset-classic";

const DOCUSAURUS_BASE_URL = process.env.DOCUSAURUS_BASE_URL ?? "/";

const config: Config = {
future: {
// See https://github.com/facebook/docusaurus/issues/10556
experimental_faster: true
},
title: "Prisma Documentation",
tagline:
"Get started with Prisma in the official documentation, and learn more about all Prisma's features with reference documentation, guides, and more.",
Expand Down
Loading

0 comments on commit 80029e2

Please sign in to comment.