Query optimisation: share initial snapshots across LIMIT variants of the same query (donor windows)
Maintainers usually reply within 1 day
@sprihaanand-juspay is already working on this.
Since Nov 30, 2026.
Assessment
This issue has not been assessed yet.
Description
Problem
Two subscriptions that differ only in LIMIT each issue their own
PostgreSQL snapshot read:
SELECT * FROM tickets WHERE status = 'OPEN'
ORDER BY created_at DESC, id ASC LIMIT 50; -- read LIMIT 100 → PG round-trip
SELECT * FROM tickets WHERE status = 'OPEN'
ORDER BY created_at DESC, id ASC LIMIT 20; -- read LIMIT 40 → PG round-trip (redundant)
The second read fetches rows the first already holds in memory. Today twin sharing only matches structurally identical queries (by_query is keyed on the full SingleTableReadQuery, which includes limit — src/model/query.rs), so LIMIT 20 and LIMIT 50 never meet.
Proposal
When a new subscription has the same table, filter, and ORDER BY as an existing one but a smaller limit, serve it from the existing subscription's held rows (share_rows) instead of reading storage again.
OPEN tickets LIMIT 50 → SELECT ... LIMIT 100 → PG round-trip
OPEN tickets LIMIT 20 → reuse the 50's rows → 0 PG reads
This is the donor model: registration-time only. After registration the child is independent — own Window, own frontier, own refills. The engine
already works this way for twins (shared row images via subscriber tags; per-sub window in windows: IdMap<SubId, Window>), so Phase 1 mostly relaxes the lookup.
- Dominant language
- Rust
- Stars
- 129
- Forks
- 7
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from juspay/streamgres
-
Make the top-L client diff cost depend on what changed, not on the limitPossibly taken @SahilKhan101 claimed this 2 days ago. Openenhancement
juspay/streamgres#64 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 Over a week Newbie friendliness 38/100
juspay/streamgres#56 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
juspay/streamgres#55 ·
Maintainers usually reply within 1 day
-
PgBouncer transaction pooling: `prepare` runs outside the read transaction and can land on another backendPossibly taken @sprihaanand-juspay claimed this 6 days ago. Open
juspay/streamgres#53 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
juspay/streamgres#49 ·
Maintainers usually reply within 1 day
All issues in juspay/streamgres
Similar issues
-
Test connection's password prompt says the password is never saved, also for a keychain profileOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
area: settings bug Haiku review: no-score ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MMFoundation/WallpaperMachine#346 ·
Maintainers usually reply within 1 day
-
Make the HTTP server's keep-alive and headers timeouts configurablePossibly taken @mattgodbolt claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
compiler-explorer/compiler-explorer#9902 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jonathanong/no-mistakes#5490 ·
-
follow-up
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day