Open
Description
Is your feature request related to a problem?
Our query engine should rewrite
SELECT 1, URL, COUNT(*) AS c FROM hits ORDER BY c DESC LIMIT 10;
to
SELECT 1, URL, c FROM (SELECT URL, COUNT(*) AS c FROM hits ORDER BY c DESC LIMIT 10);
or
SELECT 1, URL, c FROM (SELECT URL, COUNT(*) AS c FROM hits) ORDER BY c DESC LIMIT 10;
The latter queries are more efficient due to smaller hash table key which opens up opportunity to use a specialized hash table implementation, but even within the same hash table implementation having less key columns is beneficial.
Describe the solution you'd like.
No response
Describe alternatives you've considered.
No response
Full Name:
Andrei Pechkurov
Affiliation:
QuestDB
Additional context
No response