Skip to content

Take amount of filtered into account for query_plan_join_swap_table - #73534

Merged
vdimir merged 3 commits into
masterfrom
vdimir/optimize_join_filter_granules_count
Dec 20, 2024
Merged

vdimir merged 3 commits into
masterfrom
vdimir/optimize_join_filter_granules_count

Conversation

@vdimir

@vdimir vdimir commented Dec 18, 2024

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

...

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-not-for-changelog This PR should not be mentioned in the changelog label Dec 18, 2024
@robot-ch-test-poll

robot-ch-test-poll commented Dec 18, 2024 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit 1f4c18b with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help❌ failure
Successful checks
Check nameDescriptionStatus
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There can be extreme cases, e.g. just 1 out of 1 million granules is eliminated by the index lookup which is equal to not doing an index lookup at all.
Not sure but maybe it makes sense to avoid this by adding a "usefulness" threshold, e.g. 90% of granules are filtered out?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The important part is that we get a number of rows close to the estimated one. My assumption was that if we either don’t touch the columns with an index at all (in which case we have no idea how much data is filtered and therefore don’t make any estimation), or if the index is applied, we likely won’t filter much data using this filter at runtime.
Of course, we can have multiple filters or issues with granularity, and it could still be the case. But I’m not sure if a threshold would really help here. What’s more important is that the estimation is lower than the estimation for another table. Perhaps we could set a threshold for that instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As far as I see if the index_stats is not empty, it will always contain IndexType::None as a first item (because MergeTreeDataSelectExecutor::filterPartsByPartition is always called before MergeTreeDataSelectExecutor::filterPartsByPrimaryKeyAndSkipIndexes, and the former one always puts an IndexType::None into the index_stats result and I couldn't find any other place where we populate a vector like that.

Am I right? If yes, then I think the code is okay, but it might worth to add a comment about it. If I am mistaken, then we might have have some issues if IndexType::None can come after any other index.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In my understanding, that’s the case. I added a comment stating that we expect IndexType::None as the first element. If that’s not true, we won’t apply the optimization. I suppose it’s alright to stay conservative in this case.

@vdimir
vdimir force-pushed the vdimir/optimize_join_filter_granules_count branch from 7ec5412 to 80b1baf Compare December 18, 2024 13:06
@vdimir

vdimir commented Dec 19, 2024

Copy link
Copy Markdown
Member Author

Integration tests (asan, old analyzer) [1/6] — fail: 1, passed: 598 Details
Integration tests (tsan) [1/6] — fail: 1, passed: 592 Details

test_dictionaries_postgresql/test.py::test_background_dictionary_reconnect

Stateless tests (tsan, s3 storage) [3/3] — fail: 1, passed: 2363, skipped: 71 Details

02798_explain_settings_not_applied_bug, fixing in #73615

Stress test (asan) — Possible deadlock on shutdown (see gdb.log) Details

#64838 ?

@vdimir
vdimir enabled auto-merge December 19, 2024 12:13
@vdimir
vdimir added this pull request to the merge queue Dec 20, 2024
Merged via the queue into master with commit 3e14c54 Dec 20, 2024
@vdimir
vdimir deleted the vdimir/optimize_join_filter_granules_count branch December 20, 2024 15:22
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 20, 2024
robot-clickhouse added a commit that referenced this pull request Dec 20, 2024
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created-cloud deprecated label, NOOP label Dec 20, 2024
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Dec 20, 2024
vdimir added a commit that referenced this pull request Dec 20, 2024
Backport #73534 to 24.12: Take amount of filtered into account for query_plan_join_swap_table
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants