Query optimisation: share initial snapshots across LIMIT variants of the same query (donor windows)

オープン
#58 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sprihaanand-juspay がすでに取り組んでいます。

2026年11月30日 から。

評価

この issue はまだ評価されていません。

説明

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.

主要言語
Rust
スター
129
フォーク
7
平均マージ
1日 19時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

juspay/streamgres のほかの issue

juspay/streamgres の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。