perf(logs): read the unfiltered query log count from the maintained counter - #279
Merged
Merged
Conversation
…ounter The query log's pager asks count_logs for its total on every load. With no filter applied that total is the table's row count, which the insert batch, the prune and Clear All already maintain in settings for the Database Health card. Counting it instead walked the smallest index end to end. count_logs now reads the counter when append_log_filters added no condition, which also covers a blank search box, through the same read_log_count total_log_count uses. Any filter still counts. logs_page_miss_bench, unfiltered count: - 370 677-row database: 1 387 -> 3 pages - 1 482 708-row database: 6 230 -> 3 pages Every other reading is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
==========================================
+ Coverage 91.14% 91.16% +0.01%
==========================================
Files 31 31
Lines 11401 11400 -1
==========================================
+ Hits 10392 10393 +1
+ Misses 1009 1007 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixtures are written with the sqlite3 CLI, so they bypass the write paths that maintain query_log_count. The unfiltered query log count now reads that counter, which left logs_no_js reporting "Page 1 / 1" for a fixture holding three pages. Server::seed now recomputes the counter after every fixture, which also keeps the Database Health card honest on seeded instances. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Sep 14, 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
The query log's pager asks
count_logsfor its total on every load. With no filter applied, that total is just the table's row count. The insert batch, the prune and Clear All already maintain that number insettings(query_log_count) for the Database Health card, butcount_logscounted it again, walking the smallest index end to end.count_logs: reads the counter whenappend_log_filtersadded no condition. That covers a blank search box too. Any filter still counts.read_log_count: the counter readtotal_log_countalready did, pulled out so both callers share it. Its fallback toCOUNT(*)when the counter row is missing is unchanged.Page misses
logs_page_miss_bench, same database copies andBENCH_NOW=1789212354as the #278 baseline:The other 41 readings are identical before and after on both databases.
Tests
the_unfiltered_query_log_count_is_read_rather_than_counted(tests/stats_page_miss_test.rs). Before the change it failed withno filter read 67 pages and counting the same rows read 172; after the change it passes. It covers both no filter and a blank search.the_log_count_follows_every_write_that_changes_it: usedcount_logs(None, …)as its independent "real count", which now reads the counter itself. It checks against the rows returned byquery_logsinstead, and adds the blank-search case.the_total_log_count_is_read_rather_than_counted: also used an unfilteredcount_logsas its counted baseline. It now uses a*search, which matches every row.sqlite3CLI, so they bypass the write paths that maintain the counter. On the first CI run,logs_no_jsshowedPage 1 / 1for a three-page fixture (#log-pagination contains "Page 1 / 3": last saw "Prev Page 1 / 1 Next").Server::seednow recomputesquery_log_countafter every fixture, which also keeps the Database Health card correct on seeded instances. Locally,cargo test --test specsends withall spec cases passed.Test plan
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo nextest run: 681 passed, 8 skippedlogs_page_miss_benchbefore/after on both databasescd e2e && cargo test --test specs: all spec cases passed🤖 Generated with Claude Code