-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Probably the 3 lines with most perf impact I've written in a while. |
For the sake of completeness, here's the script I used to generate the test data (warning: it took 10 minutes on my machine).
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge as is as sqlx-migrate
currently does not support concurrent index operations. We'll block inserts for a couple seconds but plugin-server will retry safely.
We'll need to invest into supporting concurrent index operations for the near future though, as we want the ability to tune these indexes as we iterate on the code.
This will likely block inserts for a bit due to a limitation on sqlx. We are hoping is fine. The issue is that sqlx runs all migrations in transactions, but See https://redirect.github.com/launchbadge/sqlx/issues/767 for more details. |
Thanks for checking the indexes, this is great. |
Our current index is bad.
I created a database and table with 100 million jobs and ran the dequeue tx query as a prepared statement:
Notice the following:
Solution: A partial index (after all, we only dequeue available jobs, no need to index other values) with the correct column order:
Down to 8ms in a 100 million rows:
Notice the following:
TODO for later: We should prepare the queries as statements to save parsing time. AFAIK sqlx does not do this for us (it has a
prepare
method but I think it's only used to check types, not the actualPREPARE
command in Postgres)