-
Notifications
You must be signed in to change notification settings - Fork 0
Performance enhancemnets for prod data #23
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
Conversation
Performance enhancements for prod data
| cb."challengeId" AS challenge_id, | ||
| MAX(cb."billingAccountId") FILTER (WHERE cb."billingAccountId" IS NOT NULL) AS billing_account_id | ||
| FROM challenges."ChallengeBilling" cb | ||
| WHERE cb."billingAccountId" = '80000062' |
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.
[maintainability]
The hardcoded billing account ID '80000062' in the WHERE clause could be extracted as a parameter to improve maintainability and flexibility of the query. This would allow for easier changes in the future if the billing account ID needs to be updated or if the query needs to be reused with different IDs.
| FROM challenges."Challenge" c | ||
| JOIN bill b | ||
| ON b.challenge_id = c.id | ||
| WHERE c."createdAt" >= now() - interval '4 months' |
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 now() - interval '4 months' in the WHERE clause could lead to inconsistent results if the query is run multiple times within a short period. Consider using a fixed date or a parameter to ensure consistent results across executions.
| bc."registrationStartDate" AS registration_start_date, | ||
| CASE | ||
| WHEN bc.status = 'COMPLETED' | ||
| AND bc."createdAt" > '2025-01-01T00:00:00Z' |
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.
[maintainability]
The condition bc."createdAt" > '2025-01-01T00:00:00Z' is hardcoded and may become obsolete over time. Consider using a parameter or a configuration setting to make this condition more flexible and maintainable.
| AND bc.status = 'COMPLETED' | ||
| AND bc."createdAt" > '2025-01-01T00:00:00Z' | ||
| ) cp ON TRUE | ||
| WHERE bc.billing_account_id = '80000062' |
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 ORDER BY bc."createdAt" DESC clause assumes that createdAt is indexed and will perform well. Ensure that there is an appropriate index on createdAt to avoid potential performance issues with large datasets.
No description provided.