-
Notifications
You must be signed in to change notification settings - Fork 109
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 index get maybe latest version #6562
base: main
Are you sure you want to change the base?
Add index get maybe latest version #6562
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis change introduces a missing database index for the Changes
Sequence Diagram(s)sequenceDiagram
participant Runner as Migration Runner
participant Migration as Improve-Version-Index Migration
participant DB as PostgreSQL Database
Runner->>+Migration: Execute run() method
Migration->>+DB: Run CREATE INDEX CONCURRENTLY SQL
DB-->>-Migration: Return query result
Migration-->>-Runner: Migration completed
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.changeset/purple-dryers-develop.md (1)
1-5
: The changeset looks good but could benefit from more details.The changeset correctly identifies the patch and describes the addition of the index, but it could be enhanced with more information such as:
- A reference to the GitHub issue Improve DB index for
getMaybeLatestVersion
database query #6249- The performance impact of this change
- An example of the affected query pattern
--- 'hive': patch --- -Added missing index for postgres db field "schema_versions.target_id" sorted with "created_at" +Added missing index for postgres db field "schema_versions.target_id" sorted with "created_at" + +This index improves the performance of the `getMaybeLatestVersion` function by optimizing queries that filter by target_id and sort by created_at. + +Fixes: https://github.com/graphql-hive/console/issues/6249
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.changeset/purple-dryers-develop.md
(1 hunks)packages/migrations/src/actions/2025.02.27T00-00-00.improve-version-index-3.ts
(1 hunks)packages/migrations/src/run-pg-migrations.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`.changeset/**`: A special folder with the files created/man...
.changeset/**
: A special folder with the files created/managed by Changesets tool.
In PRs that already includes this file, please make sure that the content of the markdown file includes:
- Full description of the change
- A link to the relevant GitHub issues (if any)
- Example with before/after
- If the change is of type
major
, please ensure that the content have content about migration with before/after.
.changeset/purple-dryers-develop.md
🔇 Additional comments (2)
packages/migrations/src/run-pg-migrations.ts (1)
162-162
: Import of new migration looks good.The new migration is correctly added to the migrations array, maintaining the chronological order based on the date in the filename.
packages/migrations/src/actions/2025.02.27T00-00-00.improve-version-index-3.ts (1)
1-12
: Migration implementation looks good.The migration correctly:
- Uses
noTransaction: true
which is required forCREATE INDEX CONCURRENTLY
- Creates an index on
target_id
withcreated_at DESC
which aligns with the goal of optimizing thegetMaybeLatestVersion
function- Names the index appropriately to reflect its purpose
Running the following query with
Without this index:
after:
I am not sure this index actually improves the performance here. |
Background
Addressing: #6249
Added index for getMaybeLatestVersion
Description
Created postgres migration for schema_versions on target_id sorted by created_id.
Ran
db:migrator
and it ran successfully