conductor
conductor copied to clipboard
Optimise the postgres queries for popping messages
Pull Request type
- [x] Refactoring (no functional changes, no api changes)
NOTE: Please remember to run ./gradlew spotlessApply to fix any format violations.
Changes in this PR
The previous behaviour for popping messages off a queue when using Postgres was:
- SELECT potential messages using
peekMessageswhile locking them for update - Loop through those messages in Conductor and update them to pop them
This means that Postgres is holding open a transaction and lock over the course of multiple queries
The new behaviour is to do the exact same thing but in a single statement so that at worst it will half the number of queries made when popping a message and reduce the amount of time a lock is held on records.
It doesn't change the behaviour at all.