Skip to content

Sync create indexes for ci_sources_pipelines pipeline_id conversion

Tianwen Chen requested to merge 422826-sync-index into master

What does this MR do and why?

Sync create indexes for ci_sources_pipelines pipeline_id conversion

This is the second step to synchronously create indexes for ci_sources_pipelines

See https://docs.gitlab.com/ee/development/database/adding_database_indexes.html#add-a-migration-to-create-the-index-synchronously

See the following output from postgres.ai that async index is completed on prod:

Table "public.ci_sources_pipelines"
                Column                |  Type   | Collation | Nullable |                     Default                      | Storage | Compression | Stats target | Description 
--------------------------------------+---------+-----------+----------+--------------------------------------------------+---------+-------------+--------------+-------------
 id                                   | integer |           | not null | nextval('ci_sources_pipelines_id_seq'::regclass) | plain   |             |              | 
 project_id                           | integer |           |          |                                                  | plain   |             |              | 
 pipeline_id                          | integer |           |          |                                                  | plain   |             |              | 
 source_project_id                    | integer |           |          |                                                  | plain   |             |              | 
 source_pipeline_id                   | integer |           |          |                                                  | plain   |             |              | 
 source_job_id                        | bigint  |           |          |                                                  | plain   |             |              | 
 partition_id                         | bigint  |           | not null |                                                  | plain   |             |              | 
 source_partition_id                  | bigint  |           | not null |                                                  | plain   |             |              | 
 pipeline_id_convert_to_bigint        | bigint  |           |          |                                                  | plain   |             |              | 
 source_pipeline_id_convert_to_bigint | bigint  |           |          |                                                  | plain   |             |              | 
Indexes:
    "ci_sources_pipelines_pkey" PRIMARY KEY, btree (id)
    "index_ci_sources_pipelines_on_pipeline_id" btree (pipeline_id)
    "index_ci_sources_pipelines_on_pipeline_id_bigint" btree (pipeline_id_convert_to_bigint)
    "index_ci_sources_pipelines_on_project_id" btree (project_id)
    "index_ci_sources_pipelines_on_source_job_id" btree (source_job_id)
    "index_ci_sources_pipelines_on_source_partition_id_source_job_id" btree (source_partition_id, source_job_id)
    "index_ci_sources_pipelines_on_source_pipeline_id" btree (source_pipeline_id)
    "index_ci_sources_pipelines_on_source_pipeline_id_bigint" btree (source_pipeline_id_convert_to_bigint)
    "index_ci_sources_pipelines_on_source_project_id" btree (source_project_id)
Foreign-key constraints:
    "fk_be5624bf37_p" FOREIGN KEY (source_partition_id, source_job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE
    "fk_d4e29af7d7" FOREIGN KEY (source_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE
    "fk_e1bad85861" FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE
Triggers:
    trigger_68d7b6653c7d BEFORE INSERT OR UPDATE ON ci_sources_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_68d7b6653c7d()
Access method: heap

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #422826 (closed)

Edited by Marius Bobin

Merge request reports