Files
usdt/sql/rent_dashboard_indexes.sql

20 lines
1.0 KiB
SQL

-- 角色看板的可选性能升级;不修改业务数据,不影响旧接口。
-- MySQL DDL会隐式提交,建议维护窗口执行;按索引名检查,可重复执行。
SET @rent_dashboard_ddl = IF(
EXISTS(SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE()
AND table_name='rent_order' AND index_name='idx_order_supplier_dashboard'),
'SELECT 1',
'ALTER TABLE rent_order ADD INDEX idx_order_supplier_dashboard (supplier_user_id,network,created_at)');
PREPARE rent_dashboard_stmt FROM @rent_dashboard_ddl;
EXECUTE rent_dashboard_stmt;
DEALLOCATE PREPARE rent_dashboard_stmt;
SET @rent_dashboard_ddl = IF(
EXISTS(SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE()
AND table_name='rent_ledger' AND index_name='idx_ledger_dashboard'),
'SELECT 1',
'ALTER TABLE rent_ledger ADD INDEX idx_ledger_dashboard (account_id,created_at)');
PREPARE rent_dashboard_stmt FROM @rent_dashboard_ddl;
EXECUTE rent_dashboard_stmt;
DEALLOCATE PREPARE rent_dashboard_stmt;