watermill-sql
watermill-sql copied to clipboard
Add index for mysql and postgres
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_shortfor a quick check. - If you want to run all tests, use
make test.
- If you are testing a Pub/Sub, you can start Docker with
- [X] Code has no breaking changes.
- [ ] (If applicable) documentation on watermill.io is updated.
- Documentation is built in the github.com/ThreeDotsLabs/watermill/docs.
- You can find development instructions in the DEVELOP.md.