questdb / questdb/questdb

Improve performance of filtered distinct symbol query

Open
#4,279 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement Performance SQL
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?

A query like

SELECT DISTINCT node_uid FROM request_logs

runs fast because it uses the symbol table (metadata) and doesn't have to scan the whole node_id table. However, if we add a filter:

SELECT DISTINCT node_uid FROM request_logs WHERE node_id != NULL

the query enters a full table scan, filtering out NULLs.

Describe the solution you'd like.

We can rewrite the query to

SELECT * FROM (SELECT DISTINCT node_uid FROM request_logs) WHERE node_uid != NULL

This would do the same work as the first query above, and then filter out a possible single NULL row.

Describe alternatives you've considered.

No response

Full Name:

Marko Topolnik

Affiliation:

QuestDB

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the planner or execution path for SELECT DISTINCT with a WHERE filter, then compare it with the symbol-table path used by the unfiltered query. Reproduce both SQL examples and verify that the filtered query avoids a full node_id table scan while excluding NULL results.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.