上传源代码版本
This commit is contained in:
41
add_indexes.sql
Normal file
41
add_indexes.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
-- =====================================================
|
||||
-- 索引优化SQL脚本
|
||||
-- 执行前请先备份数据库
|
||||
-- 执行时间:建议在系统低峰期执行
|
||||
-- =====================================================
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- =====================================================
|
||||
-- label_replace_requests 表索引优化
|
||||
-- =====================================================
|
||||
|
||||
-- 添加 CustomerId 索引
|
||||
ALTER TABLE `label_replace_requests`
|
||||
ADD INDEX `idx_customer_id` (`CustomerId` ASC);
|
||||
|
||||
-- 添加 FinalMileTrackingNumber 索引
|
||||
ALTER TABLE `label_replace_requests`
|
||||
ADD INDEX `idx_final_mile_tracking_number` (`FinalMileTrackingNumber` ASC);
|
||||
|
||||
-- 添加组合索引 (CustomerId, CreatedAt)
|
||||
ALTER TABLE `label_replace_requests`
|
||||
ADD INDEX `idx_customer_id_created_at` (`CustomerId` ASC, `CreatedAt` DESC);
|
||||
|
||||
-- =====================================================
|
||||
-- label_scan_history 表索引优化
|
||||
-- =====================================================
|
||||
|
||||
-- 添加组合索引 (CustomerId, NeutralWaybillNumber)
|
||||
ALTER TABLE `label_scan_history`
|
||||
ADD INDEX `idx_customer_id_neutral_waybill_number` (`CustomerId` ASC, `NeutralWaybillNumber` ASC);
|
||||
|
||||
-- =====================================================
|
||||
-- 验证索引是否添加成功
|
||||
-- =====================================================
|
||||
|
||||
-- 查看 label_replace_requests 表的索引
|
||||
SHOW INDEX FROM `label_replace_requests`;
|
||||
|
||||
-- 查看 label_scan_history 表的索引
|
||||
SHOW INDEX FROM `label_scan_history`;
|
||||
Reference in New Issue
Block a user