watermill-sql icon indicating copy to clipboard operation
watermill-sql copied to clipboard

Add index for mysql and postgres

Open sdil opened this issue 4 weeks ago • 0 comments

Motivation / Background

I'm trying to optimize table schema by addind index on both MySQL and Postgres adapter.

Details

I noticed that the SELECT query access pattern for the queue tables always has the WHERE acked = false and ORDER BY "offset" ASC clauses. For PostgreSQL, I added a partial index to optimize this query, and for MySQL, I added an index on this column.

Disclaimer: Claude Code helped me with this optimization.

Alternative approaches considered (if applicable)

N/A

Checklist

The resources of our team are limited. There are a couple of things that you can do to help us merge your PR faster:

  • [ ] I wrote tests for the changes.
  • [X] All tests are passing.
    • If you are testing a Pub/Sub, you can start Docker with make up.
    • You can start with make test_short for a quick check.
    • If you want to run all tests, use make test.
  • [X] Code has no breaking changes.
  • [ ] (If applicable) documentation on watermill.io is updated.

sdil avatar Jan 06 '26 16:01 sdil