Optimize DISTINCT + ORDER BY
See original GitHub issueFollowing Slack discussion : https://apache-pinot.slack.com/archives/C011C9JHN7R/p1623782718117700
Context Documents: 100M Segments: 90
Query Getting DISTINCT values for a low cardinality column (45 distinct STRINGs)
Query select DISTINCT(kpi) from kpis
takes ~10ms
While select DISTINCT(kpi) from kpis ORDER BY kpi
takes more than 300ms
Please have a look at the discussion by @mayankshriv and @kishoreg for more technical details
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
DISTINCT with ORDER BY very slow - sql - Stack Overflow
CREATE INDEX call_logs_timestamp ON public.call_logs USING btree (timestamp) TABLESPACE pg_default;. I have tried the below index but does not ...
Read more >MySQL 8.0 Reference Manual :: 8.2.1.18 DISTINCT Optimization
Because DISTINCT may use GROUP BY , learn how MySQL works with columns in ORDER BY or HAVING clauses that are not part...
Read more >How to speed up select distinct? - DBA Stack Exchange
Select first row in each GROUP BY group? Optimize GROUP BY query to retrieve latest row per user. Either way, if time intervals...
Read more >SQL Server ORDER BY performance tips
The Distinct Sort Operator performs eliminating the duplicate rows and sort operations at the same time. 1. SELECT DISTINCT p ...
Read more >SQL SERVER - Distinct and ORDER BY
The main question which I received is around, why ORDER BY is not required with the DISTINCT. Well, the answer is pretty simple....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would say that we document this behaviour and make users aware of this scenario. WDYT?
Since we have agreement, marking the issue as closed.