Rewrite GROUP BY queries with constant keys
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.3k
- Forks
- 1.6k
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 28
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides SQL examples for rewriting GROUP BY queries with constant keys, but names no files, tests, or entry points. Start by locating the query-engine planning or rewrite code, then verify that the rewritten form preserves query results while reducing the hash-table key columns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100