diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2021-12-14 12:34:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-14 12:34:30 +0000 |
commit | a4dce5b53dd460e7c6757648ff4a348b490c6213 (patch) | |
tree | 92e9f608c727a246002fffb2ff81b7cc410d6a55 /synapse/storage/databases/main/registration.py | |
parent | Add missing type hints to synapse.http. (#11571) (diff) | |
download | synapse-a4dce5b53dd460e7c6757648ff4a348b490c6213.tar.xz |
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.
Diffstat (limited to 'synapse/storage/databases/main/registration.py')
-rw-r--r-- | synapse/storage/databases/main/registration.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/synapse/storage/databases/main/registration.py b/synapse/storage/databases/main/registration.py index 86c3425716..29d9d4de96 100644 --- a/synapse/storage/databases/main/registration.py +++ b/synapse/storage/databases/main/registration.py @@ -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 """ ) |