[Group Hierarchy] Create database table
Create a new model called Namespaces::Descendants
(plural on purpose) to store de-normalized descendant record ids.
Table structure:
CREATE TABLE namespace_descendants (
namespace_id bigint NOT NULL,
self_and_descendant_group_ids bigint[] NOT NULL DEFAULT ARRAY[]::bigint[],
all_project_ids bigint[] NOT NULL DEFAULT ARRAY[]::bigint[],
traversal_ids bigint[] NOT NULL DEFAULT ARRAY[]::bigint[],
outdated_at timestamp with time zone, -- outdated_at IS NULL means it's not outdated
calculated_at timestamp with time zone,
PRIMARY KEY(namespace_id)
)
PARTITION BY HASH (namespace_id);
Consider list-partitioning when creating the table. The partitions should be created in the gitlab_partitions_static
schema. Use 32 partitions.
You can see the migration from the PoC here: !134499 (diffs)
Note: for now don't add extra indexes to the table.
Edited by Adam Hegyi