mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
perf(migrations): index map_events_daily by day
Its key starts with the zone, so the economy compaction read the whole table twice for every day it merged into a month. With 900k old rows to merge on MariaDB the task went from 107 s to 14 s. The index holds only the day and the key, so the game's upsert that adds to a row's events never updates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4
migrations/dlu/mysql/75_map_events_day_index.sql
Normal file
4
migrations/dlu/mysql/75_map_events_day_index.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
/* map_events_daily's key starts with the zone, so everything that reads it by day alone read the whole table: the
|
||||
economy compaction (twice per day it merges into a month, a whole table scan each) and the reports over every zone.
|
||||
The index holds only the day and the key, so adding events to a row (the game's upsert) never has to update it. */
|
||||
CREATE INDEX map_events_daily_day ON map_events_daily (day);
|
||||
2
migrations/dlu/sqlite/58_map_events_day_index.sql
Normal file
2
migrations/dlu/sqlite/58_map_events_day_index.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
/* map_events_daily by day, for the economy compaction and the reports over every zone: see the MySQL migration */
|
||||
CREATE INDEX IF NOT EXISTS map_events_daily_day ON map_events_daily (day);
|
||||
Reference in New Issue
Block a user