Skip to content

Partition notes table

As the initial step towards reducing the size of the notes table, we need to partition the table. We don't plan on splitting the table at the moment, and will just hash partition by multiple columns.

See #396797 (comment 1324459936) and https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/notes_table_partitioning/ for more details.

Proposed steps

Step 1:

  • Add namespace_id column to notes
  • Add namespace_id foreign key constraint and index
  • Make sure notes.namespace_id is populated correctly when notes are created, cloned (when cloning and moving issues), and imported
  • Backfill notes.namespace_id for old notes

Step 2:

  • Add other indexes which include namespace_id
  • Make sure queries to notes include a namespace_id clause

Step 3:

  • Create partitioned copy of notes
  • Backfill the partitioned copy
  • Finalize backfill and swap the tables
Edited by Thong Kuah