studio
studio copied to clipboard
Prisma Studio Out of Memory
Bug description
Creating a one to many relationship table with a large quantity of many (1M+) causes prisma studio to fail to load the table due to memory issues. This makes sense if I was trying to display the entire row, including the relations. But when I select just a column or two that are not part of the relations, it still fails to load.
How to reproduce
// schema.prisma
datasource db {
provider = "postgresql" // Change this to the database you are using
url = env("DATABASE_URL")
}
model Product {
id Int @id @default(autoincrement())
name String
sales Sale[] // Relation field
}
model Sale {
id Int @id @default(autoincrement())
saleDate DateTime
amount Float
productId Int
product Product @relation(fields: [productId], references: [id])
}
// with 2-5 products, write 1M+ sales
Expected behavior
Query just the columns of question as to not run out of memory
Prisma information
prisma : 5.3.1
@prisma/client : 5.1.1
Current platform : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 61e140623197a131c2a6189271ffee05a7aa9a59 (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Schema Engine : schema-engine-cli 61e140623197a131c2a6189271ffee05a7aa9a59 (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/schema-engine-debian-openssl-1.1.x)
Schema Wasm : @prisma/prisma-schema-wasm 5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59
Default Engines Hash : 61e140623197a131c2a6189271ffee05a7aa9a59
Studio : 0.494.0
Environment & setup
- OS: Linux Ubuntu
- Browser: Chrome or Microsoft Edge (browser independent)
- Database: PostgreSQL Note, running in a docker
Prisma logs
prisma:query COMMIT prisma:query SELECT 1 prisma:query BEGIN
@janpio
I don't know if this is related, but here is the error we are getting when trying to load a table with lots of relations (from our cluster):
node:events:498
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open '/app/node_modules/prisma/engines/34ace0eb2704183d2c05b60b52fba5c43c13f303/libquery_engine-debian-openssl-3.0.x.so.node'
Emitted 'error' event on ReadStream instance at:
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/app/node_modules/prisma/engines/34ace0eb2704183d2c05b60b52fba5c43c13f303/libquery_engine-debian-openssl-3.0.x.so.node'
}
Node.js v22.3.0
It is very consistent and reproduces every time, regardless of:
-
Filters
, -
Showing
(i.e. pagination).
Changing any params (such as doing Take 1
) still crashes the Prisma Studio pod, as I assume it tries to load relations in-memory.
Here's part of our schema.prisma
:
generator client {
provider = "prisma-client-js"
// TODO: Enabling this actually _reduces_ performance (albeit it should be increasing it). What we are experiencing is similar to the issue described here https://github.com/prisma/prisma/discussions/22288#discussioncomment-7847470
// previewFeatures = ["relationJoins", "nativeDistinct"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}