Skip to content

[pull] main from sqliteai:main - #61

Merged
pull[bot] merged 1 commit into
tigawanna:mainfrom
sqliteai:main
Sep 23, 2026
Merged

pull[bot] merged 1 commit into
tigawanna:mainfrom
sqliteai:main

Conversation

@pull

@pull pull Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

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 : )

…#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]>
@pull pull Bot locked and limited conversation to collaborators Sep 23, 2026
@pull pull Bot added the ⤵️ pull label Sep 23, 2026
@pull
pull Bot merged commit b75146e into tigawanna:main Sep 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant