prisma / studio

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

Failed to open table browser if the table has a many-to-many field with too many rows #1053

Open hiramhuang opened 1 year ago

hiramhuang commented 1 year ago

Bug description

This error occurred when I try to open a table in the Prisma Studio, the table I tried to open had a many-to-many field to another table (table B), table B has more than 100k rows at the time.

The database is hosted on PlanetScale, with the default setting it cannot query more than 100k rows.

This is the error message shown on the modal:

Message: Error in Prisma Client request: 

Invalid `prisma.brand.findMany()` invocation:

Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1105, message: "target: DATABASE_NAME.-.primary: vttablet: rpc error: code = Aborted desc = Row count exceeded 100000 (CallerID: planetscale-admin)", state: "HY000" })) })

Query shown with the error message:

{
  "modelName": "Brand",
  "operation": "findMany",
  "args": {
    "take": 100,
    "skip": 0,
    "select": {
      "id": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_STRING_FIELD": true,
      "A_NUMBER_FIELD": true,
      "A_NUMBER_FIELD": true,
      "A_DATE_FIELD": true,
      "A_DATE_FIELD": true,
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      },
      "A_MANY_TO_MANY_FIELD": {
        "select": {
          "id": true
        }
      }
    }
  }
}

I don't know details about how Prisma Studio works, but it seems possible to count those many-to-many fields without selecting the id of the field. (just a thought)

I tried to un-select those many-to-many fields from the "fields option" on the data browser, but nothing changed.

How to reproduce

  1. Start Prisma Studio.
  2. Opens a table in the data browser.
  3. The error modal shows up.

Expected behavior

No response

Prisma information

I'm working on a closed-source project and preferred not to share the schema publicly. If the schema can help with this issue, please DM me, and I can share it privately.

Environment & setup

Screenshot of page where the problem happened (if applicable)

No response

Prisma logs

No response

petradonka commented 1 year ago

Thanks for sharing details about the issue you're running into. We'll take a look and it's on our mid-term backlog right now.