Commit 0af4b17
db: composite index on releases (published_at, id) (#762)
db: composite index on releases (published_at, id) for cursor walks (#756)
GraphQL latestReleases and REST /v1/orgs/:slug/releases both order by
(published_at DESC, id DESC) and tiebreak the cursor on id when
published_at is equal. The existing idx_releases_published only covers
published_at alone, so ties (common — batch ingest stamps dozens of rows
with one poll-cycle timestamp) force a temp B-tree filesort over the
tied range.
Add a hand-authored DESC composite index. Drizzle's index() helper
doesn't emit direction, so the schema declaration is best-effort; the
migration carries the real DDL.
Verified on staging via EXPLAIN QUERY PLAN:
- Before: SEARCH USING INDEX idx_releases_published (published_at<?)
+ USE TEMP B-TREE FOR LAST TERM OF ORDER BY
- After: SEARCH USING COVERING INDEX idx_releases_published_id (published_at<?)
Single-column idx_releases_published is left in place — many REST queries
still filter/order on published_at alone and the optimizer may prefer the
narrower index for those scans. Drop is a follow-up if EXPLAIN later
shows it unused.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 69eaefb commit 0af4b17
2 files changed
Lines changed: 28 additions & 0 deletions
File tree
- packages/core/src
- workers/api/migrations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
273 | 278 | | |
274 | 279 | | |
275 | 280 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments