Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

PostgreSQL: index for the AT_TIMESTAMP stream seek needs a data migration

未关闭
#467 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
postgresql, rust
领域
databases

调研方向

Start by reading the existing data migration files under crates/storage-postgres/data_migrations/ and the migrations::DATA_MIGRATIONS list. Add a migration for the covering (shard_id, created_at, sequence_number) index, then update the catalog-converge and backup tests that enumerate migrations. Done when those tests include the migration and existing deployments can run extenddb migrate before serving the upgraded binary.

由索引模型根据 Issue 内容生成。

描述

The AT_TIMESTAMP seek on PostgreSQL runs SELECT MIN(sequence_number) FROM stream_records WHERE shard_id = $1 AND created_at >= $2. The planner takes the minimum off the (shard_id, sequence_number) primary key and applies created_at as a heap filter; the global created_at index cannot yield the minimum sequence without a sort, so it is not chosen. With sequence and creation time correlated, a seek near the tip filters the whole shard.

Measured on one shard of 100,000 records with created_at spread over 24 hours: a seek at the start answers in 0.04 ms (first row qualifies), a mid-range seek in 9.46 ms (49,999 rows removed by filter), a seek near the tip in 19.21 ms (99,899 rows removed). Linear in shard size beyond that.

A covering index (shard_id, created_at, sequence_number) gives the minimum directly. It needs a data migration file under crates/storage-postgres/data_migrations/ and an entry in migrations::DATA_MIGRATIONS, which means existing deployments run extenddb migrate before the upgraded binary serves, and the catalog-converge and backup tests that enumerate the migration list need the new file added. That upgrade step is why the index is not part of the feature change; GetShardIterator runs about once per consumer resume, so the cost is tolerable until a hot shard holds millions of records.

MongoDB and SQLite got their (shard_id, created_at) index in the feature change itself, since both create indexes idempotently at startup.

主要语言
Rust
星标
517
派生
60
平均合并
2 天 23 小时
30 天内合并 PR
25

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ExtendDB/extenddb 的其他 Issue

查看 ExtendDB/extenddb 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。