[DevEx]: Partition the `gamestaterow` table of the database on the `"gameId"` column
Feature Summary
We should partition the gamestaterow table on the "gameId" column in the production database. This issue is to create the migration script to execute that change
Detailed Description
The gamestaterow table will quickly grow to be the largest table in the system. It is almost exclusively queried via
const game = await Game.findOne({ id: gameId })
.populate('p0')
.populate('p1')
.populate('gameStates', { sort: 'createdAt ASC' });
which hopefully translates to querying like
select *
from "gamestaterow" g
where "gameId" = :gameId;
As the table grows, this query will slow down. To keep its performance manageable, we should partition the table into multiple tables based on "gameId", which postgres can use to more effieicently query for any given gamestaterow based on its gameId.
See postgres partitions for details on the approach
Hey, can you assign me this ? i would like to work on this