Skip to content

Prisma 7 much worse on typescript compilation #29011

Closed

Description

@mmahalwy

Bug description

This is a summary from Claude

Comparison: Prisma 6 vs Prisma 7

Performance & Memory Metrics Comparison

Metric Prisma 6 Prisma 7 Change
TypeScript Compilation Time 60.23s 62.97s +4.5% slower
Memory Used (tsc) 5,531MB 7,298MB +32% more memory
Total Types 1,585,693 5,093,854 +221% more types
Type Instantiations 11,441,158 30,242,287 +164% more instantiations
Files Analyzed 9,371 8,951 -4.5% fewer files
Total Lines 4,137,772 2,136,914 -48% fewer lines
Model Files Size 31MB (603,685 lines) 31MB (607,567 lines) ~Same size
tsserver Memory 816MB + 162MB 22MB + 20MB -95% less (after conversion)

Key Differences

  1. Prisma 7 is WORSE for TypeScript Performance:
    - 30.2 million type instantiations (vs 11.4M in v6)
    - 7.3GB memory usage (vs 5.5GB in v6)
    - 5 million types generated (vs 1.6M in v6)
  2. Model File Structure Changed:
    // Prisma 7 - Still heavy but different structure
    export type QuoteModel = runtime.Types.Result.DefaultSelection<Prisma.$QuotePayload>
  3. vs Prisma 6:
    export type QuoteModel = runtime.Types.Result.DefaultSelection<Prisma.$QuotePayload>
  4. Why Prisma 7 is Worse:
    - 3x more type instantiations (30M vs 11M)
    - 3x more types generated (5M vs 1.6M)
    - 32% more memory usage
    - Similar compilation time but with much higher resource usage

Critical Finding

Prisma 7 made the TypeScript performance problem significantly WORSE:

  • Type instantiations increased by 164%
  • Memory usage increased by 32%
  • Total types increased by 221%

This explains why the lightweight conversion to Prisma.GetPayload<{}> types is even more critical with Prisma 7. The newer version generates substantially more complex type definitions, causing:

  • Exponential growth in type checking complexity
  • Massive memory consumption
  • Slower IDE responsiveness

Severity

⚠️ Major: Breaks core functionality (e.g., migrations fail)

Reproduction

Hard to reproduce.

Expected vs. Actual Behavior

See the report above

Frequency

Consistently reproducible

Does this occur in development or production?

Only in development (e.g., CLI tools, migrations, Prisma Studio)

Is this a regression?

Yes. Upgrading from 6 -> 7.2.0.

Workaround

Downgrading.

Prisma Schema & Queries

// Add relevant schema.prisma snippet
// Add relevant Prisma Client query

This is a massive project

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS: macOs
  • Database: PostgreSQL
  • Node.js version: 22

Prisma Version

// Prisma version output

prisma : 7.2.0
@prisma/client : 7.2.0
Operating System : darwin
Architecture : arm64
Node.js : v22.14.0
TypeScript : 5.9.3
Query Compiler : enabled
PSL : @prisma/prisma-schema-wasm 7.2.0-4.0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
Schema Engine : schema-engine-cli 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3 (at node_modules/.pnpm/@prisma[email protected]/node_modules/@prisma/engines/schema-engine-darwin-arm64)
Default Engines Hash : 0c8ef2ce45c83248ab3df073180d5eda9e8be7a3
Studio : 0.9.0
Preview Features : fullTextSearchPostgres, relationJoins, views

Activity

  1. added
    kind/bug
    on Jan 8, 2026
  2. mmahalwy commented on Jan 8, 2026

    @mmahalwy
    Author

    Another test I just ran

    TypeScript Performance Comparison: Prisma 6 vs Prisma 7

    Here's the comparison after downgrading back to Prisma 6:

    Performance Metrics

    Metric Prisma 6 Prisma 7 Improvement
    Total Time 49.19s 62.97s 22% faster ✅
    Memory Used 4.4GB 7.3GB 40% less memory ✅
    Type Instantiations 8.5M 30.2M 72% fewer ✅
    Total Types 1.5M 5.1M 71% fewer ✅
    Check Time 17.48s 55.55s 69% faster ✅
    Parse Time 4.96s 4.52s Similar
    Total Lines 2.1M 2.1M Same

    Key Findings

    Prisma 6 is significantly better for TypeScript performance:

    1. 3.5x fewer type instantiations (8.5M vs 30.2M)
    2. 3.4x fewer types generated (1.5M vs 5.1M)
    3. 40% less memory usage (4.4GB vs 7.3GB)
    4. 22% faster overall compilation (49s vs 63s)
    5. Type checking specifically is 69% faster (17.5s vs 55.5s)

    Summary

    The downgrade to Prisma 6 provides:

    • Dramatic performance improvement - 22% faster compilation
    • Much lower memory footprint - 2.9GB less RAM usage
    • Better developer experience - Faster IDE responsiveness
    • Reduced type complexity - 72% fewer type instantiations

    Recommendation: Stay on Prisma 6 until Prisma addresses the significant performance regression in v7. The v7 upgrade introduced massive type complexity that makes TypeScript compilation significantly slower and
    more memory-intensive.

  3. mmahalwy commented on Jan 13, 2026

    @mmahalwy
    Author

    I guess this isnt important?

  4. yigitahmetsahin commented on Jan 19, 2026

    @yigitahmetsahin

    Similar issue also reported in #28776 . @jacek-prisma can you please also check here.

  5. Aluisio commented on Jan 22, 2026

    @Aluisio

    @mmahalwy Yesterday version 7.3.0 was released. Could you run the benchmarks again? It would also be interesting to know the performance difference between compilerBuild fast and small.

  6. yigitahmetsahin commented on Jan 28, 2026

    @yigitahmetsahin

    @mmahalwy have you observed any improvements with the new version?

  7. Xetoxyc commented on Jan 28, 2026

    @Xetoxyc

    @yigitahmetsahin at least we do not feel like anything is faster, we still have to wait mutliple seconds even with 7.3
    No matter on the compiler build option

    i do not have this performance overview as @mmahalwy does

  8. added
    bug/1-unconfirmed
    on Feb 4, 2026
  9. mmahalwy commented on Feb 10, 2026

    @mmahalwy
    Author

    @Aluisio i can run this test tonight. Sorry for the late reply here.

  10. mmahalwy commented on Feb 11, 2026

    @mmahalwy
    Author

    @Aluisio it doesnt make a difference at all....

    Here's the GitHub comment:


    Prisma 7.3 compilerBuild — fast vs small vs Prisma 6.19

    TypeScript Performance

    All benchmarks run with --incremental false, --noEmit.

    Metric Prisma 6.19 7.3 fast (default) 7.3 small
    Total Time 29.80s 79.89s 93.58s
    Check Time 24.17s 72.87s 84.15s
    Memory Used 5,153 MB 7,407 MB 7,227 MB
    Types 1,525,148 5,415,051 5,415,051
    Instantiations 8,754,755 30,683,924 30,683,924
    Symbols 4,647,754 6,173,204 6,173,204

    What compilerBuild Actually Does

    The compilerBuild option only changes the runtime WASM query compiler bundle — it swaps 3 import references in class.ts between query_compiler_fast_bg and query_compiler_small_bg. That's it.

    It has zero impact on TypeScript type generation. The generated types, models, and internal namespace files are byte-for-byte identical between fast and small. All type metrics (Types, Instantiations, Symbols) are exactly the same.

    Key Takeaway

    compilerBuild is a runtime performance vs bundle size tradeoff for the WASM query compiler:

    • fast = larger WASM (4.6 MB), optimized for query execution speed
    • small = smaller WASM (2.3 MB), optimized for serverless/edge bundle size

    It does nothing to address the TypeScript performance regression (3.5× more type instantiations, 2.7× slower compilation). The core problem remains in the @prisma/client/runtime/client.d.ts type definitions, which compilerBuild doesn't touch.

  11. Aluisio commented on Feb 11, 2026

    @Aluisio
  12. sanny-io commented on Feb 11, 2026

    @sanny-io

    @Aluisio you may be confusing compile/build time typescript compilation performance vs runtime query performance related to query compilation.

    Those are not the same thing. This issue is regarding typescript compilation at compile/build time.

  13. mmahalwy commented on Feb 18, 2026

    @mmahalwy
    Author

    @sanny-io correct. @Aluisio this has to do with typescript, not the engine.

  14. timAdrien commented on Feb 27, 2026

    @timAdrien

    I'm experiencing the same problem. My production build takes infinite type checking, I debugged and it's effectively the resolution of millions of types for only few tables that takes so long... How is that possible to release a such thing ? CPU hang on it:

    Image
  15. vincentrolfs commented on Mar 20, 2026

    @vincentrolfs

    This issue makes Prisma 7 unusable for us. See also the related #28967

  16. 16 remaining items

  17. mmahalwy commented on May 28, 2026

    @mmahalwy
    Author

    @jacek-prisma this is getting frustrating, we literally cannot upgrade to any 7.x version. This is the latest for 247 models

    Image
  18. Aluisio commented on May 28, 2026

    @Aluisio

    To me it's clear: Prisma 7 was released prematurely, and with the development of the new Prisma "next," it's been forgotten.

    What worries me most is that Prisma "next" will alter the syntax and have major breaking changes, which will make migration impossible for large, professional projects.

    I'm still using version 6 and I'm already convinced that I'll hardly migrate to another version. How am I going to rewrite more than 1000 selects in a Prisma update to the "next" version? Impossible!

    If I have to rewrite my code, I'll seriously consider migrating to another ORM as well.

  19. osulli commented on May 29, 2026

    @osulli

    To me it's clear: Prisma 7 was released prematurely, and with the development of the new Prisma "next," it's been forgotten.

    What worries me most is that Prisma "next" will alter the syntax and have major breaking changes, which will make migration impossible for large, professional projects.

    I'm still using version 6 and I'm already convinced that I'll hardly migrate to another version. How am I going to rewrite more than 1000 selects in a Prisma update to the "next" version? Impossible!

    If I have to rewrite my code, I'll seriously consider migrating to another ORM as well.

    Sort of in the same boat. To migrate to Prisma 7 now seems like a footgun - I'm waiting on 1.0 of Drizzle to do a comparison - I was originally against Drizzle as I don't like writing SQL and with Drizzle being closer to SQL I was against it but... then I realised that in all honesty Claude writes 99.9% of any DB queries anyway so.

    I hope Prisma Next becomes a reasonable choice by the time Drizzle 1.0 is out as otherwise Prisma is out of the running which will be a shame.

    Prisma 6 is doing just fine for now though but my concern is that it is now "2 versions" behind in Prisma's eyes so it can't be a long-term pick anymore.

  20. sanny-io commented on May 29, 2026

    @sanny-io

    @Aluisio @osulli you should consider using ZenStack. Its function signatures and schema are Prisma compatible, but it's powered by Kysely, and includes many new features. I have switched to it a while ago and it's been great.

    https://zenstack.dev

  21. nfl1ryxditimo12 commented on May 30, 2026

    @nfl1ryxditimo12
    Contributor

    Hi 👋 cc @jacek-prisma @jkomyno @aqrln — apologies for the direct ping. I spent some time digging into this regression and opened #29592 with what looks like a small, targeted fix. It would be great if someone could take a look when review bandwidth allows.

    As far as I can tell, the regression traces back to #28375, which changed the OmitOpts default on the PrismaClient interface from its constraint to undefined:

    - in out OmitOpts extends Prisma.PrismaClientOptions['omit'] = Prisma.PrismaClientOptions['omit'],
    + in out OmitOpts extends Prisma.PrismaClientOptions['omit'] = undefined,

    This seems to unintentionally revert the short-circuit optimization from #27777 / ORM-850. My current understanding is that when the default equals the constraint, a bare PrismaClient — the common “no client options” case — resolves OmitOpts to its constraint, allowing TypeScript to reuse a single canonical instantiation across model delegates.

    With = undefined, each delegate appears to be re-instantiated with { omit: undefined }, which re-runs the omit-application chain (ExtractGlobalOmit → ApplyOmit) per model × per operation. That seems consistent with the ~30M type instantiations reported here. I have not traced the compiler internals, so please treat this part as my best-effort explanation.

    One thing I did confirm: the resolved result types are identical either way — both apply no global omit — so this appears to be an evaluation-cost regression rather than a behavior change.

    Rough benchmark on a 406-model schema using tsgo --extendedDiagnostics:

    Metric = undefined current = …['omit'] fix Improvement
    Type Instantiations 32.8M 2.65M ~12×
    Check time 16.97s 2.47s ~7×

    More detail is in #29592. Please feel free to correct me if I missed something — I’m happy to adjust the PR if there is a better way to approach this.

  22. added a commit that references this issue on Jun 1, 2026
    868ffdd
  23. mmahalwy commented on Jun 12, 2026

    @mmahalwy
    Author

    I love you all for fixing this.... but this has been open since Jan. It took ~6 months for a 1-line change? 😓

  24. Aluisio commented on Jun 25, 2026

    @Aluisio

    @mmahalwy Just a single line, and they still haven't released the fix.
    It's clear they are focused on Prisma Next and aren't concerned with maintaining versions 6 and 7.

  25. SagnikPradhanPearSuite commented on Jul 14, 2026

    @SagnikPradhanPearSuite

    In case anybody is interested, you can add a small bash script to patch it manually after every generation

    #!/usr/bin/env bash
    set -euo pipefail
    
    FILE="./generated/internal/class.ts" # Change this
    FROM="Prisma\.PrismaClientOptions\['omit'\] = undefined"
    TO="Prisma.PrismaClientOptions['omit'] = Prisma.PrismaClientOptions['omit']"
    
    sed "s|$FROM|$TO|" "$FILE" > "$FILE.tmp"
    mv "$FILE.tmp" "$FILE"
    
    if grep -qF "$TO" "$FILE"; then
      echo "Applied Prisma omit type workaround to $FILE"
    else
      echo "Warning: Failed to apply Prisma omit type workaround to $FILE" >&2
    fi
  26. added a commit that references this issue on Aug 9, 2026
    3ed00c9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedkind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions