prisma / studio

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

Prisma studio easily hits Planetscale's 100,000 row read system limit #1260

Open reubenjh opened 3 months ago

reubenjh commented 3 months ago

Bug description

When prisma studio spins up, it defaults to fetching all of the relations in order to show a count in the UI. This causes it to hit Planetscale's row read limit of 100,000 in a reasonably large project. The engine exits with a non 0 status code and I see an error including these blocks: PrismaClientKnownRequestError:x,PrismaClientRustPanicError:D,PrismaClientInitializationError:P,PrismaClientValidationError:A and rpc error: code = Aborted desc = Row count exceeded 100000.

Even if you toggle off the offending joined fields, that only toggles them out of visibility, but the underlying query still includes them.

This is confirmed by looking at the underlying query, which in both cases whether the fields are toggled on or off is as follows in my case:

Query:
{
  "modelName": "Card",
  "operation": "findMany",
  "args": {
    "take": 50,
    "skip": 0,
    "select": {
      "id": true,
      "slug": true,
      "name": true,
      "hotscore": true,
      "guardian": true,
      "reverse": true,
      "references": {
        "select": {
          "id": true
        }
      },
      "referencedBy": {
        "select": {
          "id": true
        }
      },
      "faqs": {
        "select": {
          "id": true
        }
      },
      "elements": {
        "select": {
          "id": true
        }
      },
      "keywords": {
        "select": {
          "id": true
        }
      },
      "variants": {
        "select": {
          "id": true
        }
      },
      "setCards": {
        "select": {
          "id": true
        }
      },
      "deckCards": {
        "select": {
          "id": true
        }
      },
      "avatarCards": {
        "select": {
          "id": true
        }
      },
      "sideboardCards": {
        "select": {
          "id": true
        }
      },
      "maybeboardCards": {
        "select": {
          "id": true
        }
      },
      "deckChange": {
        "select": {
          "id": true
        }
      },
      "collectionItems": {
        "select": {
          "id": true
        }
      },
      "collectionChange": {
        "select": {
          "id": true
        }
      },
      "tournamentDeckCards": {
        "select": {
          "id": true
        }
      },
      "tournamentAvatarCards": {
        "select": {
          "id": true
        }
      },
      "tournamentSideboardCards": {
        "select": {
          "id": true
        }
      }
    }
  }
}

How to reproduce

Not possible without a database with sufficient data.

Expected behavior

I have found a workaround which includes shrinking the number in the take argument down until the joined rows is low enough, but this won't scale as as some point I won't even be able to fetch 1 item.

I can no longer use prisma studio at this point, which is a major issue and has me considering an alternative, and I expect anyone else on Planetscale with a decent amount of data is experiencing the same thing.

My recommendation is to change those select: { id: true }statements in the underlying query to simple counts, or have toggling the fields off actually turn them off from the query and have them defaulted off.

Prisma information

version 5.16.2 schema doesnt matter, nothing else is broken.

Environment & setup

Running npx prisma studio against a Planetscale database with sufficiently high data.

Prisma logs

No response

connerludlow commented 2 months ago

+1