Skip to content

Add condition cache query profiling#81

Open
peterxcli wants to merge 1 commit into
mainfrom
peter/query-profile
Open

Add condition cache query profiling#81
peterxcli wants to merge 1 commit into
mainfrom
peter/query-profile

Conversation

@peterxcli

@peterxcli peterxcli commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Closes: #80

Introduce profiling, allowing cache status and statistics to be surfaced in EXPLAIN ANALYZE output and JSON profiling.

  • Added a ConditionCacheProfileInfo to store profiling data (cache status, predicate hash, cached row groups, qualifying vectors, etc.) for each condition cache entry and propagate it through query planning and execution.
  • Modified the optimizer (QueryConditionCacheOptimizer) to create and attach ConditionCacheProfileInfo to each cache entry, and propagate this information through the optimizer state and into the logical plan.
  • Introduced ConditionCacheTableScanBindData to wrap table scan bind data with profiling info, and updated the logical get node and filter binding to use and copy this profiling data.
  • Implemented ConditionCacheDynamicToString to surface cache profiling information in EXPLAIN ANALYZE and JSON profiling output, including status, predicate hash, and statistics.

Signed-off-by: peterxcli <peterxcli@gmail.com>

@dentiny dentiny left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this PR, should we have sql tests (with EXPLAIN ANALYZE)?

@peterxcli

Copy link
Copy Markdown
Collaborator Author

For this PR, should we have sql tests (with EXPLAIN ANALYZE)?

yes, we already have it

query II
EXPLAIN (ANALYZE, FORMAT JSON) SELECT count(*) FROM t WHERE id < 3000;
----
analyzed_plan	<REGEX>:.*"Condition Cache": "MISS -> BUILT".*"Condition Cache Predicate Hash": "[0-9]+".*"Condition Cache Cached Row Groups": "5".*"Condition Cache Qualifying Vectors": "2/245".*

@peterxcli peterxcli requested a review from dentiny April 24, 2026 05:17
@dentiny

dentiny commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Could you please paste the overall ANALYZE output in the PR description?

@dentiny dentiny left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick review

};

struct ConditionCacheProfileInfo {
atomic<bool> initial_lookup_hit {false};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment needed


struct ConditionCacheProfileInfo {
atomic<bool> initial_lookup_hit {false};
atomic<bool> built_this_query {false};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment needed, also we should name the variable as noun_verb_ed

idx_t total_row_groups;
};

struct ConditionCacheProfileInfo {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment needed, does the struct indicate a cache entry, singular/composite predicate, or a user query, a user connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per Query Stats

2 participants