Skip to content

Conversation

zhyass
Copy link
Member

@zhyass zhyass commented Sep 19, 2025

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

Summary

This PR introduces automatic ANALYZE after write operations with the following enhancements:

  1. Auto analyze after DML operations

    • Since HLL statistics only account for inserted rows (but not deleted ones), table statistics may become inaccurate.
    • To fix this, an automatic ANALYZE will be triggered after MERGE INTO, DELETE, UPDATE, and REPLACE INTO operations.
    • Auto analyze will only run when the statistics deviation exceeds 10%.
  2. New table option: enable_auto_analyze

    • Newly created tables have enable_auto_analyze = 1 (enabled by default).

    • For existing tables, users need to manually enable it via:

      ALTER TABLE t SET OPTIONS(enable_auto_analyze = 1);
    • When enabling on an existing table, a full ANALYZE will be executed to update historical statistics.

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

@zhyass zhyass marked this pull request as draft September 19, 2025 17:58
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Sep 19, 2025
@zhyass zhyass added the ci-benchmark Benchmark: run all test label Sep 24, 2025
Copy link
Contributor

Docker Image for PR

  • tag: pr-18754-095242f-1758678988

note: this image tag is only available for internal use.

@zhyass zhyass changed the title feat: enable auto analyze after write feat: enable analyze hook after DML Sep 24, 2025
@zhyass zhyass marked this pull request as ready for review September 24, 2025 15:56
@dantengsky dantengsky requested review from b41sh and removed request for b41sh September 26, 2025 14:18
@dantengsky dantengsky merged commit 2e69c7f into databendlabs:main Sep 27, 2025
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-benchmark Benchmark: run all test pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants