Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries on taxi dataset are slow with ps=1 #1316

Closed
githubmanticore opened this issue Aug 2, 2023 · 1 comment
Closed

Queries on taxi dataset are slow with ps=1 #1316

githubmanticore opened this issue Aug 2, 2023 · 1 comment

Comments

@githubmanticore
Copy link
Contributor

Queries on partial taxi dataset (6 indexes) are almost 2x slower with pseudo_sharding enabled:

mysql> set global pseudo_sharding=0; SELECT avg(total_amount) FROM taxi WHERE trip_distance = 5; show meta; 
Query OK, 0 rows affected (0.00 sec) 
 
+-------------------+ 
| avg(total_amount) | 
+-------------------+ 
|       17.94111949 | 
+-------------------+ 
1 row in set (0.07 sec) 
 
+----------------+-------------------------------------+ 
| Variable_name  | Value                               | 
+----------------+-------------------------------------+ 
| total          | 1                                   | 
| total_found    | 1                                   | 
| total_relation | eq                                  | 
| time           | 0.065                               | 
| index          | trip_distance:SecondaryIndex (100%) | 
+----------------+-------------------------------------+ 
5 rows in set (0.00 sec) 
 
mysql> set global pseudo_sharding=1; SELECT avg(total_amount) FROM taxi WHERE trip_distance = 5; show meta; 
Query OK, 0 rows affected (0.00 sec) 
 
+-------------------+ 
| avg(total_amount) | 
+-------------------+ 
|       17.94111949 | 
+-------------------+ 
1 row in set (0.12 sec) 
 
+----------------+----------------------------------------------------------------------+ 
| Variable_name  | Value                                                                | 
+----------------+----------------------------------------------------------------------+ 
| total          | 1                                                                    | 
| total_found    | 1                                                                    | 
| total_relation | eq                                                                   | 
| time           | 0.122                                                                | 
| index          | trip_distance:SecondaryIndex (18%), trip_distance:ColumnarScan (81%) | 
+----------------+----------------------------------------------------------------------+ 
5 rows in set (0.00 sec) 

This needs to be fixed.

@githubmanticore
Copy link
Contributor Author

➤ Ilya Kuznetsov commented:

Incorrect CBO path selection was due to 2 things:

  1. CBO didn't account for the fact that implicit group sorter is faster than plain group sorter
  2. Histograms sometimes gave VERY misleading estimates when value distribution is uneven. Changed max histogram size from 1k to 8k which helped a lot (requires reindexing to work).

Fixed those issues in 92d722a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants