du sql query: eliminate use of count(a.*)#72
Open
andrewbogott wants to merge 3 commits intowamdam:masterfrom
Open
du sql query: eliminate use of count(a.*)#72andrewbogott wants to merge 3 commits intowamdam:masterfrom
andrewbogott wants to merge 3 commits intowamdam:masterfrom
Conversation
The particular syntax count(a.*) in this query doesn't parse on mariadb (or, presumably, mysql). Counting a.uid is equivalent; we can be confident that there aren't any rows without uid set because the query includes 'a.uid is not NULL'. Addresses wamdam#71
david-caro
reviewed
Jan 8, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The particular syntax count(a.*) in this query doesn't parse
on mariadb (or, presumably, mysql). Counting a.uid is equivalent;
we can be confident that there aren't any rows without uid
set because the query includes 'a.uid is not NULL'.
Addresses #71
Here are examples in mariadb:
mysql:galera_backup@localhost [eqiad1_ceph_backy]> select a.uid, a.size, count(a.) from blocks a where a.version_uid="bc7eae94-d8f8-11ea-8823-f0921c05f570" and a.uid is not NULL;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') from blocks a where a.version_uid="bc7eae94-d8f8-11ea-8823-f0921c05f570" and ' at line 1
mysql:galera_backup@localhost [eqiad1_ceph_backy]> select a.uid, a.size, count(a.uid) own_shared, (select count(*) cnt from blocks where uid=a.uid) shared from blocks a where a.version_uid="bc7eae94-d8f8-11ea-8823-f0921c05f570" and a.uid is not NULL group by a.uid, a.size limit 2;
+----------------------------------+---------+------------+--------+
| uid | size | own_shared | shared |
+----------------------------------+---------+------------+--------+
| 000f3a5685vDGo3bcSJEXE4i34ioQHAd | 4194304 | 1 | 4 |
| 009da580dfystrfRKiYZMEBX4dFbbSw6 | 4194304 | 1 | 4 |
+----------------------------------+---------+------------+--------+
2 rows in set (0.033 sec)