Skip to content

fix(stores): add LIMIT clause to DELETE statements in lookup functions#98

Merged
mroderick merged 1 commit intomainfrom
feature/add-delete-limit
Apr 29, 2026
Merged

fix(stores): add LIMIT clause to DELETE statements in lookup functions#98
mroderick merged 1 commit intomainfrom
feature/add-delete-limit

Conversation

@mroderick
Copy link
Copy Markdown
Contributor

@mroderick mroderick commented Apr 29, 2026

Add LIMIT 10 to the DELETE statements that remove expired records in all SQL store implementations. This prevents the lookup function from taking a long time when there are many expired records to clean up.

Changes

  • PostgreSQL: DELETE ... WHERE key IN (SELECT key ... LIMIT 10) - uses subquery since PostgreSQL doesn't support LIMIT in DELETE directly
  • MySQL (Node): DELETE ... LIMIT 10
  • MySQL (Deno): DELETE ... LIMIT 10
  • Bun SQL: Uses PostgreSQL subquery syntax for PostgreSQL connections, direct LIMIT for MySQL/SQLite

Notes

  • SQLite already had LIMIT 10 implemented
  • All unit tests and integration tests pass
  • The LIMIT ensures cleanup operations don't block lookup requests when there are many expired records
  • This fixes an oversight where DELETE statements could scan and delete unbounded numbers of expired records

@mroderick mroderick force-pushed the feature/add-delete-limit branch from 8005a9a to 7169914 Compare April 29, 2026 11:04
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 29, 2026

Deploying idempot-js with  Cloudflare Pages  Cloudflare Pages

Latest commit: bc03c18
Status: ✅  Deploy successful!
Preview URL: https://4ae7a224.idempot-js.pages.dev
Branch Preview URL: https://feature-add-delete-limit.idempot-js.pages.dev

View logs

@mroderick mroderick force-pushed the feature/add-delete-limit branch 2 times, most recently from 5b3c540 to 1d89afe Compare April 29, 2026 11:28
@mroderick mroderick marked this pull request as ready for review April 29, 2026 11:31
@mroderick mroderick force-pushed the feature/add-delete-limit branch from 1d89afe to bc03c18 Compare April 29, 2026 11:37
@mroderick mroderick changed the title feat(stores): add LIMIT clause to DELETE statements in lookup functions fix(stores): add LIMIT clause to DELETE statements in lookup functions Apr 29, 2026
@mroderick mroderick merged commit bceb02f into main Apr 29, 2026
12 checks passed
@mroderick mroderick deleted the feature/add-delete-limit branch April 29, 2026 11:41
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.6 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.6 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.6 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant