perf: 增加表索引

This commit is contained in:
CaptainB 2022-11-25 14:20:44 +08:00 committed by 刘瑞斌
parent 01b0421cdf
commit 56fb3e2712
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,13 @@
--
-- 增加一个索引
SELECT IF(EXISTS(SELECT DISTINCT index_name
FROM information_schema.statistics
WHERE table_schema = DATABASE()
AND table_name = 'api_definition'
AND index_name LIKE 'api_definition_module_id_status_index'),
'select 1',
'ALTER TABLE api_definition ADD INDEX api_definition_module_id_status_index (module_id, status)')
INTO @a;
PREPARE stmt1 FROM @a;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;

View File

@ -0,0 +1,13 @@
--
-- 增加一个索引
SELECT IF(EXISTS(SELECT DISTINCT index_name
FROM information_schema.statistics
WHERE table_schema = DATABASE()
AND table_name = 'load_test_report_detail'
AND index_name LIKE 'load_test_report_detail_report_id_part_index'),
'select 1',
'ALTER TABLE load_test_report_detail ADD INDEX load_test_report_detail_report_id_part_index (report_id, part)')
INTO @a;
PREPARE stmt1 FROM @a;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;