FG
🗄️ DatabasesVercel

Support for Read Replicas (Postgres, MySQL) or setting Client in read-only mode

Fresh3 months ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

Latest update Check this comment below for the Client Extension that enables this functionality! https://github.com/prisma/prisma/issues/172#issuecomment-1718089127 🥳 --- @matthewmueller's update Problem Currently we don't support read-replicas. This is a common need for scaling databases. Solution I agree with @dpetrick's solution below. One thing I would additionally suggest is to provide a `Readonly` interface that you can pass through. This `Readonly` interface would omit the `Create`, `Update`, `Delete` methods. --- > Does prisma2 support the ability to direct queries to master db or read-only replicas based on read/write? This is useful functionality that lots of db drivers support. Hopefully since prisma2 aims to replace the db driver, it would also have this functionality. > > > (User feedback) > > This can be handled in various ways (the list if from the top of my mind): > > 1. Not natively in Prisma, have actual read/read-write nodes in the DB natively and multiple `datasource` blocks and multiple `generate` blocks to generate read-only, read-write photon. > > [code block] > > 2. Natively in Photon with a read only parameter > > [code block] > > Other ways are also possible. Additional context * https://github.com/prisma/prisma/issues/3389

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
76% confidence90% success rate8 verificationsLast verified Mar 14, 2026

Solution: Support for Read Replicas (Postgres, MySQL) or setting Client in read-only mode

Low Risk

My first intuition on the subject was neither of your options, but the possibility to provide a read-only endpoint directly in the datasource, which would cause Prisma to internally either load balance or direct all read traffic to the read db. Both your options are severely limited in use: - Option 1) requires you to annotate models with a source... and then you suddenly need 2 annotations for

76

Trust Score

8 verifications

90% success
  1. 1

    My first intuition on the subject was neither of your options, but the possibili

    My first intuition on the subject was neither of your options, but the possibility to provide a read-only endpoint directly in the datasource, which would cause Prisma to internally either load balance or direct all read traffic to the read db. Both your options are severely limited in use:

  2. 2

    Option 1) requires you to annotate models with a source... and then you suddenly

    - Option 1) requires you to annotate models with a source... and then you suddenly need 2 annotations for read and write.

  3. 3

    Option 2) would imply that the whole photon client is just throwing out write qu

    - Option 2) would imply that the whole photon client is just throwing out write queries and just allow read queries. Seems odd to me all around, because what's the point of having this when the approach is pretty much a glorified version of creating 2 photon clients and separating traffic on the client side.

  4. 4

    For me, this is the most simple and intuitive version:

    [code block] ... and Prisma handles the rest.

Validation

Resolved in prisma/prisma GitHub issue #172. Community reactions: 51 upvotes.

Verification Summary

Worked: 8
Partial: 1
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prismaormpostgresqlkind/featuretopic:-prisma-clienttopic:-schematopic:-multiple-datasources