perf(sql): sweep/KPI covering indexes + sliced notification terminal purge
This commit is contained in:
@@ -94,6 +94,23 @@ public static class StoreAndForwardSchema
|
||||
"CREATE INDEX IF NOT EXISTS idx_sf_messages_status_due ON sf_messages(status, last_attempt_at_ms)";
|
||||
dueIndex.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// Covering index for GetMessagesForRetryAsync's ORDER BY created_at ASC.
|
||||
// idx_sf_messages_status_due (above) matches the status filter and the
|
||||
// last_attempt_at_ms half of the due predicate, but its column order does
|
||||
// NOT match the query's "ORDER BY created_at ASC", so SQLite still needs a
|
||||
// sort/scan step to satisfy that ordering on a large due-sweep. This index's
|
||||
// leading (status, created_at) column order lets the planner walk matching
|
||||
// rows already in created_at order and stop at LIMIT without touching
|
||||
// non-pending rows or re-sorting (arch-review WP1.4). idx_sf_messages_status_due
|
||||
// is left in place — it still backs status+due-time lookups that don't order by
|
||||
// created_at.
|
||||
using (var orderIndex = connection.CreateCommand())
|
||||
{
|
||||
orderIndex.CommandText =
|
||||
"CREATE INDEX IF NOT EXISTS idx_sf_messages_status_created ON sf_messages(status, created_at)";
|
||||
orderIndex.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user