feat: 实现父表索引策略,确保仅在父表创建索引,避免子表重复索引维护

This commit is contained in:
2026-03-03 18:22:17 +08:00
parent cf61e8dac6
commit 0bd10dbc1e
4 changed files with 68 additions and 2 deletions

View File

@@ -38,7 +38,9 @@ ALTER TABLE rcu_action.rcu_action_events
ALTER TABLE rcu_action.rcu_action_events
ADD COLUMN IF NOT EXISTS loop_name VARCHAR(255);
-- Indexes for performance
-- Indexes for performance (ONLY on parent partitioned table)
-- PostgreSQL will create/attach corresponding child-partition indexes automatically.
-- Do not create duplicated indexes on partition child tables.
CREATE INDEX IF NOT EXISTS idx_rcu_action_hotel_id ON rcu_action.rcu_action_events (hotel_id);
CREATE INDEX IF NOT EXISTS idx_rcu_action_room_id ON rcu_action.rcu_action_events (room_id);
CREATE INDEX IF NOT EXISTS idx_rcu_action_device_id ON rcu_action.rcu_action_events (device_id);