mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 12:45:03 -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
|
@ -59,7 +59,7 @@ class MonthlyActiveUsersWorkerStore(SQLBaseStore):
|
|||
def _count_users(txn):
|
||||
# Exclude app service users
|
||||
sql = """
|
||||
SELECT COALESCE(count(*), 0)
|
||||
SELECT COUNT(*)
|
||||
FROM monthly_active_users
|
||||
LEFT JOIN users
|
||||
ON monthly_active_users.user_id=users.name
|
||||
|
@ -86,7 +86,7 @@ class MonthlyActiveUsersWorkerStore(SQLBaseStore):
|
|||
|
||||
def _count_users_by_service(txn):
|
||||
sql = """
|
||||
SELECT COALESCE(appservice_id, 'native'), COALESCE(count(*), 0)
|
||||
SELECT COALESCE(appservice_id, 'native'), COUNT(*)
|
||||
FROM monthly_active_users
|
||||
LEFT JOIN users ON monthly_active_users.user_id=users.name
|
||||
GROUP BY appservice_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue