studio
studio copied to clipboard
Prisma Studio handles models with n:m relations in a way that makes it unusable for larger DBs
Bug description
I use Prisma Studio in the browser.
Prisma studio throws timeouts when querying some tables or is extremely slow or freezes all the time. I guess this is because the requested data comes from a model that has n:m relations. Some of these relations have over 10000 connections. I guess Prisma studio uses the include option for all attributes. This leads to more than 10,000 connections being requested and sent. Since this leads to very large amounts of data, it results in a timeout/freeze.
For example, imagine you have a model user with the attribute Follower. A user has 10k followers. Prisma studio would then request the data of all 10k followers as soon as this user is requested.
Even if you unselect certain attributes in Prisma studio, they are still requested.
Actually I would say it's a feature request/improvement, but since for me it makes studio unusable on a larger DB, I would describe it as a bug.
How to reproduce
- create a model User with the n:m relation follower
- create 100k user and connect them with each other
- open Prisma Studio and open the model user
Maybe not on local host but definitely on dev/prod server the query will timeout or take forever.
Expected behavior
There is more than one option:
- not query (not include) not selected attributes of a model
- only query connected objects, if you click on a specific object and not by default.
- use _count to geht the relation count instead of select/include all relations.
Maybe you have some more or better ideas.
Prisma information
Just use a schema with large n:m relations where the relation itself maybe also contain some larger datapoints like json data.
Environment & setup
- OS: Mac OS
- Database: PostgreSQL
- Node.js version: v16.13.0
Prisma Version
prisma 3.6.0
But the behavior is the same since v2.x.x