-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inefficient index while getting delivery records
- Loading branch information
Showing
2 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
import { Migration } from "@mikro-orm/migrations"; | ||
|
||
export class Migration20250214201450 extends Migration { | ||
|
||
async up(): Promise<void> { | ||
this.addSql(`DROP INDEX delivery_record_partitioned_feed_timeframe_count;`); | ||
this.addSql(`CREATE INDEX delivery_record_partitioned_feed_timeframe_count ON delivery_record_partitioned (created_at DESC, feed_id, status);`); | ||
this.addSql( | ||
`CREATE INDEX delivery_record_partitioned_feed_timeframe_count ON delivery_record_partitioned (created_at DESC, feed_id, status);` | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql(`DROP INDEX delivery_record_partitioned_feed_timeframe_count;`); | ||
this.addSql(`CREATE INDEX delivery_record_partitioned_feed_timeframe_count ON delivery_record_partitioned (created_at, status, feed_id);`); | ||
this.addSql( | ||
`CREATE INDEX delivery_record_partitioned_feed_timeframe_count ON delivery_record_partitioned (created_at, status, feed_id);` | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Migration } from "@mikro-orm/migrations"; | ||
|
||
export class Migration20250225140642 extends Migration { | ||
override async up(): Promise<void> { | ||
this.addSql( | ||
`DROP INDEX delivery_record_partitioned_feed_parent_created_at_desc;` | ||
); | ||
this.addSql( | ||
`CREATE INDEX delivery_record_partitioned_feed_parent_created_at_desc ON delivery_record_partitioned (feed_id, created_at DESC, parent_id);` | ||
); | ||
} | ||
|
||
override async down(): Promise<void> { | ||
this.addSql( | ||
`DROP INDEX delivery_record_partitioned_feed_parent_created_at_desc;` | ||
); | ||
this.addSql( | ||
`CREATE INDEX delivery_record_partitioned_feed_parent_created_at_desc ON delivery_record_partitioned (feed_id, parent_id, created_at DESC);` | ||
); | ||
} | ||
} |