feat: add timestamp index in monitorstatushistory24h table

This commit is contained in:
zaunist committed 2025-06-27 17:32:03 +08:00
1 parent 9ad0c96d28
commit fe7afd4063
5 files changed
+1336 -1

No files matched your search

@@ -0,0 +1 @@
CREATE INDEX `monitor_status_history_24h_timestamp_idx` ON `monitor_status_history_24h` (`timestamp`);
File diff suppressed because it is too large. Load diff
+7
View File
@@ -22,6 +22,13 @@
"when": 1750852918387,
"tag": "0002_public_domino",
"breakpoints": true
},
{
"idx": 3,
"version": "6",
"when": 1751016667916,
"tag": "0003_reflective_random",
"breakpoints": true
}
]
}
+4
View File
@@ -222,5 +222,9 @@ ALTER TABLE \`agents\` DROP COLUMN \`network_tx\`;`
CREATE INDEX IF NOT EXISTS \`monitor_daily_stats_monitor_id_date_idx\` ON \`monitor_daily_stats\` (\`monitor_id\`,\`date\`);
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS \`monitor_status_history_24h_monitor_timestamp_idx\` ON \`monitor_status_history_24h\` (\`monitor_id\`,\`timestamp\`);`
},
{
name: "0003_reflective_random.sql",
sql: `CREATE INDEX IF NOT EXISTS \`monitor_status_history_24h_timestamp_idx\` ON \`monitor_status_history_24h\` (\`timestamp\`);`
}
];
+3 -1
View File
@@ -42,7 +42,9 @@ export const monitorStatusHistory24h = sqliteTable("monitor_status_history_24h",
error: text("error")
}, (table) => ({
// monitor_id 和 timestamp 的联合索引,用于优化按监控项和时间查询的性能
monitorTimestampIdx: index("monitor_status_history_24h_monitor_timestamp_idx").on(table.monitor_id, table.timestamp)
monitorTimestampIdx: index("monitor_status_history_24h_monitor_timestamp_idx").on(table.monitor_id, table.timestamp),
// timestamp 单独索引,用于优化按时间排序和范围查询的性能
timestampIdx: index("monitor_status_history_24h_timestamp_idx").on(table.timestamp)
}));
// 监控每日统计表