mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 21:14:57 -04:00
Remove redundant COALESCE()
s around COUNT()
s in database queries (#11570)
`COUNT()` never returns `NULL`. A `COUNT(*)` over 0 rows is 0 and a `COUNT(NULL)` is also 0.
This commit is contained in:
parent
33abbc3278
commit
a4dce5b53d
9 changed files with 20 additions and 21 deletions
|
@ -1393,7 +1393,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
|
|||
count = await self.db_pool.simple_select_one_onecol(
|
||||
table="federation_inbound_events_staging",
|
||||
keyvalues={"room_id": room_id},
|
||||
retcol="COALESCE(COUNT(*), 0)",
|
||||
retcol="COUNT(*)",
|
||||
desc="prune_staged_events_in_room_count",
|
||||
)
|
||||
|
||||
|
@ -1485,9 +1485,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
|
|||
"""Update the prometheus metrics for the inbound federation staging area."""
|
||||
|
||||
def _get_stats_for_federation_staging_txn(txn):
|
||||
txn.execute(
|
||||
"SELECT coalesce(count(*), 0) FROM federation_inbound_events_staging"
|
||||
)
|
||||
txn.execute("SELECT count(*) FROM federation_inbound_events_staging")
|
||||
(count,) = txn.fetchone()
|
||||
|
||||
txn.execute(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue