From 62379c93302ccebc3c93f7ca607accea9c84a4ac Mon Sep 17 00:00:00 2001 From: funera1 Date: Tue, 14 Mar 2023 13:57:09 +0900 Subject: [PATCH 1/3] Delete application_piped_id index because application_piped_id_updated_at_desc index covers the index. --- pkg/datastore/mysql/ensurer/indexes.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/datastore/mysql/ensurer/indexes.sql b/pkg/datastore/mysql/ensurer/indexes.sql index 71984fea0e..90189724a6 100644 --- a/pkg/datastore/mysql/ensurer/indexes.sql +++ b/pkg/datastore/mysql/ensurer/indexes.sql @@ -27,7 +27,8 @@ CREATE INDEX application_project_id_updated_at_desc ON Application (ProjectId, U -- index on `PipedId` ASC ALTER TABLE Application ADD COLUMN PipedId VARCHAR(36) GENERATED ALWAYS AS (data->>"$.piped_id") VIRTUAL NOT NULL; -CREATE INDEX application_piped_id ON Application (PipedId); +-- TODO: Should remove that statement after few releases. +DROP INDEX application_piped_id ON Application; -- index on `PipedId` ASC and `UpdatedAt` DESC CREATE INDEX application_piped_id_updated_at_desc ON Application (PipedId, UpdatedAt DESC); From 4fcc8025d0886dd59e3041c2028cec00df6996b5 Mon Sep 17 00:00:00 2001 From: funera1 Date: Tue, 14 Mar 2023 15:37:31 +0900 Subject: [PATCH 2/3] Fix as review --- pkg/datastore/mysql/ensurer/indexes.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/datastore/mysql/ensurer/indexes.sql b/pkg/datastore/mysql/ensurer/indexes.sql index 90189724a6..78712c278e 100644 --- a/pkg/datastore/mysql/ensurer/indexes.sql +++ b/pkg/datastore/mysql/ensurer/indexes.sql @@ -25,14 +25,13 @@ CREATE INDEX application_sync_state_updated_at_desc ON Application (SyncState_St -- index on `ProjectId` ASC and `UpdatedAt` DESC CREATE INDEX application_project_id_updated_at_desc ON Application (ProjectId, UpdatedAt DESC); --- index on `PipedId` ASC +-- index on `PipedId` ASC and `UpdatedAt` DESC ALTER TABLE Application ADD COLUMN PipedId VARCHAR(36) GENERATED ALWAYS AS (data->>"$.piped_id") VIRTUAL NOT NULL; +CREATE INDEX application_piped_id_updated_at_desc ON Application (PipedId, UpdatedAt DESC); + -- TODO: Should remove that statement after few releases. DROP INDEX application_piped_id ON Application; --- index on `PipedId` ASC and `UpdatedAt` DESC -CREATE INDEX application_piped_id_updated_at_desc ON Application (PipedId, UpdatedAt DESC); - -- -- Command table indexes -- From 02ca925f1a4de132273098a7cfc708c34180cbf1 Mon Sep 17 00:00:00 2001 From: funera1 <60760935+funera1@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:10:23 +0900 Subject: [PATCH 3/3] Update pkg/datastore/mysql/ensurer/indexes.sql Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com> --- pkg/datastore/mysql/ensurer/indexes.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/datastore/mysql/ensurer/indexes.sql b/pkg/datastore/mysql/ensurer/indexes.sql index 78712c278e..6c3c800b7a 100644 --- a/pkg/datastore/mysql/ensurer/indexes.sql +++ b/pkg/datastore/mysql/ensurer/indexes.sql @@ -29,7 +29,7 @@ CREATE INDEX application_project_id_updated_at_desc ON Application (ProjectId, U ALTER TABLE Application ADD COLUMN PipedId VARCHAR(36) GENERATED ALWAYS AS (data->>"$.piped_id") VIRTUAL NOT NULL; CREATE INDEX application_piped_id_updated_at_desc ON Application (PipedId, UpdatedAt DESC); --- TODO: Should remove that statement after few releases. +-- TODO: Should remove this statement after few releases. DROP INDEX application_piped_id ON Application; --