Skip to content

Conversation

@b41sh
Copy link
Member

@b41sh b41sh commented Nov 17, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

This PR introduces several performance optimizations to query optimizer, primarily by reducing redundant computations and simplifying call patterns.

  1. Optimized OptimizerContext::is_optimizer_disabled for Rule Skipping Checks
    The is_optimizer_disabled function is frequently invoked during the optimization process, which would repeatedly call query_settings.unchecked_apply_changes() and read the skip_list setting, parse it by comma delimiters. The skip_list is now parsed and converted into a HashSet during the initialization of OptimizerContext, eliminating redundant compute operations.
  2. Refactored Call Pattern between optimize_expression and apply_transform_rules
    optimize_expression and apply_transform_rules call each other repeatedly, this nested invocation pattern increased call stack depth and could complicate control flow. The control flow has been refactored to simplify the call stack.
  3. Cached common_super_type Results in resolve_array
    The resolve_array function frequently calls common_super_type to determine the common super type of array elements. The common_super_type function can be computationally expensive, and its repeated invocation for the same type combinations led to performance bottlenecks. A caching mechanism (using a HashSet) has been introduced to avoid redundant and expensive common type compute.
  • fixes: #[Link the issue here]

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Nov 17, 2025
@sundy-li sundy-li merged commit 06d4e1b into databendlabs:main Nov 17, 2025
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-chore this PR only has small changes that no need to record, like coding styles.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants