Skip to content

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

@itsalaidbacklife

Description

@itsalaidbacklife

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendRequires changes to the (node) backend webserverdev experienceImprovements to the code base that make it easier/better/more enjoyable to contribute to Cuttleversion-patchAn update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions