Fix full table scans in reminder storage overview queries#92
Merged
Aaronontheweb merged 1 commit intoMar 9, 2026
Merged
Conversation
…wAsync GetNextRemindersAsync had two performance bugs introduced during the provider package split (0ce1026): 1. Called GetRemindersOverviewAsync and discarded the result, loading all rows and deserializing all payloads for nothing. 2. Opened a second connection to load ALL rows (including completed) into memory, just to compute COUNT and MIN(WhenUtc) of remaining reminders. GetRemindersOverviewAsync itself had the same issue — loading all rows to compute two scalar values. Replace GetOverviewSql (SELECT * FROM table) with: - GetOverviewAggregateSql: SELECT COUNT(*), MIN(when_utc) - GetNextReminderTimeSql: SELECT when_utc ... OFFSET @Skip LIMIT 1 This eliminates all full table scans and payload deserialization from the overview/summary code paths across all three SQL providers (SqlServer, PostgreSQL, SQLite). Also adds XML doc comments to IReminderStorage.GetRemindersOverviewAsync clarifying it is for diagnostics/testing/monitoring only and must not be called from the scheduling hot path.
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetNextRemindersAsyncandGetRemindersOverviewAsyncacross all three SQL providers (SqlServer, PostgreSQL, SQLite)GetOverviewSql(which returned all columns for all rows) with two efficient aggregate queries:GetOverviewAggregateSql:SELECT COUNT(*), MIN(when_utc) WHERE is_completed = 0GetNextReminderTimeSql:SELECT when_utc ... ORDER BY when_utc OFFSET @Skip LIMIT 1GetRemindersOverviewAsynccall insideGetNextRemindersAsync(result was discarded)IReminderStorage.GetRemindersOverviewAsyncclarifying it is for diagnostics/testing/monitoring only and must not be called from the scheduling hot pathContext
GetNextRemindersAsynchad two performance bugs introduced during the provider package split (0ce1026):GetRemindersOverviewAsyncand stored result in an unused variable — loading all rows and deserializing all payloads for nothing.COUNTandMIN(WhenUtc)of remaining reminders.GetRemindersOverviewAsyncitself had the same issue — loading every row to compute two scalar values.Structural safeguard
GetOverviewSqlhas been removed from theISqlDialectinterface entirely. The only overview-related queries now return aggregate scalars, making it structurally impossible to accidentally reintroduce a full table scan through the overview path.Test plan