cuttle icon indicating copy to clipboard operation
cuttle copied to clipboard

[DevEx]: Partition the `gamestaterow` table of the database on the `"gameId"` column

Open itsalaidbacklife opened this issue 5 months ago • 1 comments

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

itsalaidbacklife avatar Jun 27 '25 14:06 itsalaidbacklife

Hey, can you assign me this ? i would like to work on this

ryuga001 avatar Oct 22 '25 14:10 ryuga001