New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@prisma/extension-optimize

Package Overview
Dependencies
Maintainers
0
Versions
1612
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/extension-optimize

This is the package for the [Prisma Client extension](https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions?utm_source=github&utm_medium=optimize-readme), which enables the use of Prisma Optimize.

  • 1.1.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-80.05%
Maintainers
0
Weekly downloads
 
Created
Source

Prisma Optimize Prisma Client extension

This is the package for the Prisma Client extension, which enables the use of Prisma Optimize.

Prisma Optimize enables developers to profile and get performance-related recommendations while developing applications with Prisma ORM.

It is part of the Prisma ecosystem, alongside other tools such as:

  • Prisma Accelerate: Global database cache with scalable connection pooling.
  • Prisma Pulse: Real-time database events with type-safe subscriptions.

Prisma is leading Data DX, a philosophy that promotes simplicity in data-driven application development. Learn more on the Data DX manifesto.

Getting started with Prisma Optimize

Resources

You can explore Optimize with the following resources:

Using Optimize

1. Launch Optimize
  1. Log in to your Prisma Data Platform account.
  2. Access and launch the Optimize dashboard by following the instructions here.
2. Add Optimize to your application
2.1. Update Your schema.prisma file

Prisma Optimize uses Prisma ORM's OpenTelemetry tracing functionality. In the generator block of your Prisma schema, add the tracing preview feature:

 generator client {
   provider        = "prisma-client-js"
+  previewFeatures = ["tracing"]
 }

Then, generate the Prisma Client:

npx prisma generate
2.2. Install the Optimize Prisma Client extension

Install the latest versions of Prisma Client and the Optimize extension:

npm install @prisma/client@latest @prisma/extension-optimize
2.3. Create an API Key via Optimize's UI and add it to your .env file

Generate an Optimize API key by following the instructions here and add it to your .env file:

OPTIMIZE_API_KEY="YOUR_OPTIMIZE_API_KEY"
2.4. Extend your Prisma Client instance with the Optimize extension

Extend your existing Prisma Client instance with the Optimize extension:

import { PrismaClient } from "@prisma/client";
import { withOptimize } from "@prisma/extension-optimize";

const prisma = new PrismaClient().$extends(withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY }));
2.5. Use Prisma Optimize to generate insights

Follow these steps to start generating query insights with Prisma Optimize:

  1. In the Optimize dashboard, click the Start recording button, then run your app.

  2. After your app runs and insights are generated for the desired queries, click the Stop recording button.

  3. Explore individual query details by clicking on them, and check the Recommendations tab for any suggested improvements to enhance query performance.

NOTE: Use the AI Explainer feature to understand recommendations and apply them within your Prisma model context.

For a hands-on learning experience, try out the step-by-step example.

Need help?

If you need assistance, reach out in the #help-and-questions channel on our Discord, or connect with our community to see how others are using Optimize.

FAQs

Package last updated on 01 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc