Repository navigation
[pull] main from sqliteai:main - #61
Merged
Merged
Conversation
…#75) The positional cursor on cloudsync_payload_chunks stated its resume lower bound only inside (db_version>? OR (db_version=? AND seq>=?)). SQLite derives a range from a disjunction only when both arms compare against the same value, and these two arms carry distinct parameters, so it derived nothing: cloudsync_changes' xBestIndex got an upper bound and a site filter with nothing saying where to start. Every call re-read the window from the beginning, evaluating cloudsync_col_value() on each discarded row, making a full drain quadratic in the number of chunks. In production this stretched one tenant's change export to ~25 minutes. State db_version>=? explicitly alongside the disjunction. It is logically implied, so the same rows are selected; it exists so the constraint loop emits a lower bound and the (db_version) index can seek. On a ~1 GB window at the 5 MiB default chunk size (194 chunks), the drain goes from 186,058 ms to 6,115 ms, and per-chunk cost from 959 ms rising with position to 31.5 ms flat. The multiplier scales with window size, so the result to rely on is that per-chunk cost no longer depends on the window at all: O(N^2) -> O(N). PostgreSQL was never affected: it writes the same disjunction with $3 in both arms, and its planner handles OR'd range bounds natively. Adds test/chunk_bench.c and a chunk-bench target, which times a real drain per chunk index and replays the same resume points in the old and fixed spellings, asserting both select the identical row. CI builds it but never runs it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )