perf(devices): drop unused status/last_seen_at indexes (write churn)

Signed-off-by: GL.iNet-Yongping.Xie <yongping.xie@gl-inet.com>
This commit is contained in:
GL.iNet-Yongping.Xie
2026-06-24 00:07:50 -07:00
parent 3b41b0b41d
commit 34c3bb4e68
+4 -2
View File
@@ -68,8 +68,10 @@ CREATE TABLE IF NOT EXISTS devices (
FOREIGN KEY (device_group_id) REFERENCES device_groups(id) ON DELETE SET NULL
);
CREATE INDEX IF NOT EXISTS idx_devices_group_id ON devices(device_group_id);
CREATE INDEX IF NOT EXISTS idx_devices_status ON devices(status);
CREATE INDEX IF NOT EXISTS idx_devices_last_seen ON devices(last_seen_at);
-- No index on status/last_seen_at: both change on every connect/disconnect (high
-- write churn during reconnect storms) but neither is used by any read query —
-- the device-list sort uses expressions ((status='online'), COALESCE(last_seen_at,0))
-- that can't use a plain column index, and nothing filters by these columns.
CREATE TRIGGER IF NOT EXISTS trg_users_updated_at
AFTER UPDATE ON users