prisma / studio

🎙️ The easiest way to explore and manipulate your data in all of your Prisma projects.
https://www.prisma.io/studio
1.86k stars 47 forks source link

Prisma Studio handles models with n:m relations in a way that makes it unusable for larger DBs #861

Open henrikuper opened 2 years ago

henrikuper commented 2 years ago

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

  1. create a model User with the n:m relation follower
  2. create 100k user and connect them with each other
  3. 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:

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

Prisma Version

prisma 3.6.0 
But the behavior is the same since v2.x.x
henrikuper commented 2 years ago

prisma/prisma#11950 might be a related issue.