From 1dac6ae85a1e0c40211adc70e52eb8750f5627da Mon Sep 17 00:00:00 2001 From: taolx0 Date: Thu, 21 Dec 2023 14:32:05 +0800 Subject: [PATCH] Add a composite index to improve the SELECT query speed --- sqle/model/utils.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sqle/model/utils.go b/sqle/model/utils.go index e393353b11..61210aef1e 100644 --- a/sqle/model/utils.go +++ b/sqle/model/utils.go @@ -189,6 +189,10 @@ func (s *Storage) AutoMigrate() error { if err != nil { return errors.New(errors.ConnectStorageError, err) } + err = s.db.Model(&SqlManage{}).AddIndex("idx_project_id_status_deleted_at", "project_id", "status", "deleted_at").Error + if err != nil { + return errors.New(errors.ConnectStorageError, err) + } err = s.db.Model(BlackListAuditPlanSQL{}).AddUniqueIndex("uniq_type_content", "filter_type", "filter_content").Error if err != nil {