Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indexes to relationship fields #5118

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

timleslie
Copy link
Contributor

When generating a @relation in Prisma with a corresponding ID field, e.g.

  assignedTo   User?     @relation("TodoassignedTo", fields: [assignedToId], references: [id])
  assignedToId Int?      @map("assignedTo")

We want to make sure that the assignedTo field in the database is indexed, as not doing so will kill performance of queries involving joins. This PR adds corresponding index statements, e.g.

  @@index([assignedToId])

@changeset-bot
Copy link

changeset-bot bot commented Mar 15, 2021

🦋 Changeset detected

Latest commit: 45de9b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@keystone-next/adapter-prisma-legacy Major
@keystone-next/fields-auto-increment-legacy Patch
@keystone-next/fields-location-google-legacy Patch
@keystone-next/fields-mongoid-legacy Patch
@keystone-next/fields-oembed-legacy Patch
@keystone-next/fields-unsplash-legacy Patch
@keystone-next/fields-legacy Patch
@keystone-next/test-utils-legacy Patch
@keystone-next/cypress-project-access-control-legacy Patch
@keystone-next/cypress-project-basic-legacy Patch
@keystone-next/cypress-project-client-validation-legacy Patch
@keystone-next/cypress-project-login-legacy Patch
@keystone-next/fields-document Patch
@keystone-next/keystone Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/H7KQQhAC1ajNqGajrX7zxhSkPmdF
✅ Preview: https://keystone-next-git-add-index-to-prisma-relationships-key-6ff374.vercel.app

@vercel vercel bot temporarily deployed to Preview March 15, 2021 04:22 Inactive
@timleslie timleslie requested a review from emmatown March 15, 2021 04:36
@timleslie timleslie merged commit 2ff9369 into master Mar 15, 2021
@timleslie timleslie deleted the add-index-to-prisma-relationships branch March 15, 2021 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants