|
Thanks a lot for the report and test case. The difference is in "duplicate_removal" phase, and only after that there is LIMIT 1.
|
10.1.37
|
MariaDB [test]> analyze format=json SELECT DISTINCT `a` ,`b` FROM `foo` GROUP BY `a` ,`b` ,`c` ,`d` limit 1;
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| ANALYZE |
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| {
|
"query_block": {
|
"select_id": 1,
|
"r_loops": 1,
|
"r_total_time_ms": 358.62,
|
"filesort": {
|
"r_loops": 1,
|
"r_total_time_ms": 0.1855,
|
"r_limit": 1,
|
"r_used_priority_queue": true,
|
"r_output_rows": 2,
|
"duplicate_removal": {
|
"temporary_table": {
|
"table": {
|
"table_name": "foo",
|
"access_type": "ALL",
|
"r_loops": 1,
|
"rows": 2000,
|
"r_rows": 2000,
|
"r_total_time_ms": 1.7921,
|
"filtered": 100,
|
"r_filtered": 100
|
}
|
}
|
}
|
}
|
}
|
} |
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.36 sec)
|
MariaDB [test]> analyze format=json SELECT `a` ,`b` FROM `foo` GROUP BY `a` ,`b` ,`c` ,`d` limit 1;
|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| ANALYZE |
|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| {
|
"query_block": {
|
"select_id": 1,
|
"r_loops": 1,
|
"r_total_time_ms": 18.394,
|
"filesort": {
|
"r_loops": 1,
|
"r_total_time_ms": 0.6903,
|
"r_limit": 1,
|
"r_used_priority_queue": true,
|
"r_output_rows": 2,
|
"temporary_table": {
|
"table": {
|
"table_name": "foo",
|
"access_type": "ALL",
|
"r_loops": 1,
|
"rows": 2000,
|
"r_rows": 2000,
|
"r_total_time_ms": 1.8729,
|
"filtered": 100,
|
"r_filtered": 100
|
}
|
}
|
}
|
}
|
} |
|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.02 sec)
|
|