mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-23 16:44:09 -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
|
@ -794,7 +794,7 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
|
|||
yesterday = int(self._clock.time()) - (60 * 60 * 24)
|
||||
|
||||
sql = """
|
||||
SELECT user_type, COALESCE(count(*), 0) AS count FROM (
|
||||
SELECT user_type, COUNT(*) AS count FROM (
|
||||
SELECT
|
||||
CASE
|
||||
WHEN is_guest=0 AND appservice_id IS NULL THEN 'native'
|
||||
|
@ -819,7 +819,7 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
|
|||
def _count_users(txn):
|
||||
txn.execute(
|
||||
"""
|
||||
SELECT COALESCE(COUNT(*), 0) FROM users
|
||||
SELECT COUNT(*) FROM users
|
||||
WHERE appservice_id IS NULL
|
||||
"""
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue