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

Prune columns from select distinct #8689

Closed
max-hoffman opened this issue Dec 18, 2024 · 0 comments · Fixed by dolthub/go-mysql-server#2796
Closed

Prune columns from select distinct #8689

max-hoffman opened this issue Dec 18, 2024 · 0 comments · Fixed by dolthub/go-mysql-server#2796
Assignees
Labels
analyzer customer issue good repro Easily reproducible bugs sql Issue with SQL

Comments

@max-hoffman
Copy link
Contributor

The plans below indicate that we are deserializing ProductName unnecessarily for the SELECT DISTINCT query, while we appropriately prune the GROUP BY. For tables with many TEXT columns this is a performance hindrance.

db/main*> CREATE TABLE Products(
                                     ProductID Char(38) PRIMARY KEY, /*UUID*/
                                     Manufacturer TEXT,
                                     ProductSeries TEXT,
                                     ProductName TEXT);
db/main*> explain plan SELECT DISTINCT Manufacturer, ProductSeries FROM Products;
+------------------------------------------------------------------+
| plan                                                             |
+------------------------------------------------------------------+
| Distinct                                                         |
|  └─ Project                                                      |
|      ├─ columns: [products.Manufacturer, products.ProductSeries] |
|      └─ Table                                                    |
|          └─ name: Products                                       |
+------------------------------------------------------------------+
5 rows in set (0.00 sec)

db/main*> explain plan SELECT Manufacturer, ProductSeries FROM Products GROUP BY Manufacturer, ProductSeries;
+------------------------------------------------------------------+
| plan                                                             |
+------------------------------------------------------------------+
| GroupBy                                                          |
|  ├─ SelectedExprs(products.Manufacturer, products.ProductSeries) |
|  ├─ Grouping(products.manufacturer, products.productseries)      |
|  └─ Table                                                        |
|      ├─ name: Products                                           |
|      └─ columns: [manufacturer productseries]                    |
+------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer customer issue good repro Easily reproducible bugs sql Issue with SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants