fix: re-create index so that it actually works#2960
Conversation
|
🍹 The Update (preview) for dailydotdev/api/prod (at 38d5c17) was successful. Resource Changes Name Type Operation
~ vpc-native-hourly-notification-cron kubernetes:batch/v1:CronJob update
~ vpc-native-validate-active-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-private-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-zombie-images-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-bg-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-tag-recommendations-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generate-search-invites-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generic-referral-reminder-cron kubernetes:batch/v1:CronJob update
~ vpc-native-temporal-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-views-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-migration-bce75232 kubernetes:batch/v1:Job create
~ vpc-native-update-highlighted-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-trending-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-source-tag-view-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-tags-str-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-stale-user-transactions-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-calculate-top-readers-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-current-streak-cron kubernetes:batch/v1:CronJob update
~ vpc-native-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-gifted-plus-cron kubernetes:batch/v1:CronJob update
~ vpc-native-daily-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-check-analytics-report-cron kubernetes:batch/v1:CronJob update
~ vpc-native-sync-subscription-with-cio-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-migration-627807ab kubernetes:batch/v1:Job delete
~ vpc-native-clean-zombie-user-companies-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-source-public-threshold-cron kubernetes:batch/v1:CronJob update
~ vpc-native-ws-deployment kubernetes:apps/v1:Deployment update
|
|
@claude compare the new index I created, to the query I intend to run. "sourceId" is dynamic based on the query. SELECT
*
FROM
source_member
WHERE
"sourceId" = '4c4a674b-c7d4-45ab-9333-1c79ef6b1d99'
AND COALESCE((flags ->> 'hasUnreadPosts')::boolean, FALSE) != TRUE; |
|
Claude finished @omBratteng's task —— View job Index AnalysisI'll compare your new index with the SQL query to ensure optimal performance. Todo List:
AnalysisYour New Index: CREATE INDEX "IDX_source_member_flags_hasUnreadPosts"
ON public.source_member ("sourceId", COALESCE((flags ->> 'hasUnreadPosts')::boolean, FALSE));Your Query: SELECT * FROM source_member
WHERE "sourceId" = '4c4a674b-c7d4-45ab-9333-1c79ef6b1d99'
AND COALESCE((flags ->> 'hasUnreadPosts')::boolean, FALSE) != TRUE;Assessment: ✅ Excellent MatchYour index is perfectly designed for this query:
Performance Benefits
Previous vs New IndexLooking at the Verdict: This index will provide excellent performance for your query pattern. Well done! 🎯 |
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(/* sql */`DROP INDEX IF EXISTS "IDX_source_member_flags_hasUnreadPosts";`); | ||
| await queryRunner.query(/* sql */`CREATE INDEX IF NOT EXISTS "IDX_source_member_flags_hasUnreadPosts" ON public.source_member ("sourceId", COALESCE((flags ->> 'hasUnreadPosts')::boolean, FALSE));`); | ||
| } |
There was a problem hiding this comment.
@capJavert thoughts on using a new migration, vs just updating the migration and running it in production?
There was a problem hiding this comment.
don't see why new migration hurts, you can call it "Fix" or something to better show what you did.
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(/* sql */`DROP INDEX IF EXISTS "IDX_source_member_flags_hasUnreadPosts";`); | ||
| await queryRunner.query(/* sql */`CREATE INDEX IF NOT EXISTS "IDX_source_member_flags_hasUnreadPosts" ON public.source_member ("sourceId", COALESCE((flags ->> 'hasUnreadPosts')::boolean, FALSE));`); | ||
| } |
There was a problem hiding this comment.
don't see why new migration hurts, you can call it "Fix" or something to better show what you did.
Previous index did not actually do anything, so new migration to make it actually work.
Jira ticket
AS-1172