matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Avoid executing no-op queries. #16583

Closed clokep closed 11 months ago

clokep commented 1 year ago

Return early for simple_insert_many_txn, simple_upsert_many_txn, and simple_update_many_txn if the iterable to update is empty.

Note that we already do this for simple_select_many_txn and simple_delete_many_txn.

This avoids hitting the database with a no-op query, the downside is that we can't pass generators into this function.

clokep commented 12 months ago

I'm not 100% convinced of these changes, I want to add some tests.

clokep commented 12 months ago

Once #16596 is merged, I'll add tests for these changes to ensure nothing is breaking.

clokep commented 11 months ago

I added some additional tests (based on #16596) and some more comments. 👍