Skip to content

Optimize minId query and improve test coverage#21

Merged
mthadley merged 5 commits intomasterfrom
optimize-min-id-calculation
Feb 19, 2026
Merged

Optimize minId query and improve test coverage#21
mthadley merged 5 commits intomasterfrom
optimize-min-id-calculation

Conversation

@mthadley
Copy link
Collaborator

@mthadley mthadley commented Feb 19, 2026

Summary

  • Uses ORDER BY ... LIMIT 1 instead of MIN() in the minId query, which allows Postgres to use an index scan instead of a full table scan
  • Switches from actions/setup-node to jdx/mise-action for Node.js version management in CI
  • Adds test coverage for minId time filter options: timestamptz cast, null result when all rows are excluded, and string (ULID) primary keys with time filtering

Test plan

  • All 297 existing tests pass with npm test -- run
  • Verify CI passes on supported Postgres versions (13, 15, 17, 18)

🤖 Generated with Claude Code

mthadley and others added 5 commits February 19, 2026 13:36
MIN() performs a full scan on large tables and can time out. Switching
to ORDER BY + LIMIT 1 leverages existing indexes on the primary key
and time columns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover timestamptz cast, null result when all rows are excluded,
and string (ULID) primary keys with time filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mthadley mthadley requested a review from stefanmb February 19, 2026 21:48
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are starting to adopt mise elsewhere so just sneaking this in (since otherwise I no longer had a global node installed when in this repo).

@mthadley mthadley merged commit 8504f4f into master Feb 19, 2026
7 checks passed
@mthadley mthadley deleted the optimize-min-id-calculation branch February 19, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants