- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6
Additional indices for performance issues noted #29
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
base: develop
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,13 @@ | |||
| -- Add indexes to support faster `/v6/my-reviews` queries. | |||
|  | |||
| CREATE EXTENSION IF NOT EXISTS pg_trgm; | |||
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.
[❗❗ correctness]
Ensure that the pg_trgm extension is supported and available in all environments where this migration will be applied. If not, this could lead to errors during deployment.
| CREATE EXTENSION IF NOT EXISTS pg_trgm; | ||
|  | ||
| CREATE INDEX IF NOT EXISTS "challenge_status_type_track_created_at_idx" | ||
| ON "Challenge" ("status", "typeId", "trackId", "createdAt" DESC); | 
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.
[performance]
Consider the impact of the createdAt DESC ordering on the index size and performance. If the table is large, this could affect write performance. Evaluate if this ordering is necessary for the query patterns.
|  | ||
| CREATE INDEX IF NOT EXISTS "challenge_name_trgm_idx" | ||
| ON "Challenge" | ||
| USING gin ("name" gin_trgm_ops); | 
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.
[performance]
Using a GIN index with gin_trgm_ops on the name column can significantly increase storage requirements. Ensure that this trade-off is justified by the performance gains in query execution.
| @@index([status, startDate]) | ||
| @@index([trackId, typeId, status]) | ||
| @@index([status, typeId, trackId, createdAt(sort: Desc)], map: "challenge_status_type_track_created_at_idx") | ||
| @@index([name], type: Gin, ops: [gin_trgm_ops], map: "challenge_name_trgm_idx") | 
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.
[❗❗ correctness]
The use of a GIN index with gin_trgm_ops on the name field is appropriate for text search. However, ensure that the pg_trgm extension is enabled in your PostgreSQL database, as it is required for gin_trgm_ops to function correctly.
| @@index([endDate]) | ||
| @@index([status, startDate]) | ||
| @@index([trackId, typeId, status]) | ||
| @@index([status, typeId, trackId, createdAt(sort: Desc)], map: "challenge_status_type_track_created_at_idx") | 
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.
[performance]
The new composite index [status, typeId, trackId, createdAt(sort: Desc)] could potentially improve query performance if these fields are frequently queried together. However, be cautious of the increased write overhead due to maintaining multiple indices. Consider analyzing query patterns to ensure this index is necessary.
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.
Looks good.
No description provided.