learningequality / learningequality/studio

Utilize database table partitioning for File and ContentNode

Open
#3,308 0 comments 0 reactions 1 assignee View on GitHub

@bjester is already working on this.

Since Feb 11, 2022.

DEV: backend Feature TAG: performance TAG: tech update / debt
Dominant language
Python
Stars
191
Forks
307
Avg merge
5d 6h
Merged PRs (30d)
10

Description

Current behavior

As studio usage has grown, database tables have grown to a size that makes performance optimization very difficult. The size makes queries or joins against these large tables very slow and therefore user operations to feel slow.

Table (hotfixes) Rows
contentcuration_contentnode 10,238,769
contentcuration_file 83,175,849

Desired behavior

There are several reasons to use table partitioning, as outlined by the postgresql documentation:

  • Partitioning the ContentNode table by tree_id could dramatically improve query performance since most will heavily access rows in a single partition and sequential scans should be quicker
  • Partitioning makes it more likely that heavily-used parts of the indexes fit in memory
  • Bulk loads and deletes are more efficient
  • Seldom-used data can be migrated to cheaper and slower storage media.

Value add

  • Pave the way for 10x data growth with current database resources

Possible tradeoffs

  • We need to update to Postgresql 12 at least
  • Might make it more difficult to migrate to Cloud Spanner afterwards
    • Cloud Spanner is globally available database that recently released postgres compatibility
    • Most postgres features we use are supported, except for transactions, which would require code updates
    • It would easily allow geographically distributed instances of Studio and greatly reduce latency
    • It may also invalidate the need for table partitioning
    • It's possible to do something like Cloud Spanner with postgres instances but would require infra
  • Determining the best strategy for partitioning the file table and achieving all the benefits

Add labels

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.