Repository navigation
Conversation
|
Workflow [PR], commit [4f22308] Summary: ❌
|
20c00a6 to
d60dd9d
Compare
Build profile diff (arm_release)Comparing Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/LeftHashJoinAntiMapsCount.cpp.o |
new | 1.58 MiB | +1.58 MiB |
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/InnerHashJoinAnyMapsCount.cpp.o |
new | 1.58 MiB | +1.58 MiB |
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/RightHashJoinAntiMapsCountWithRef.cpp.o |
new | 1.58 MiB | +1.58 MiB |
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/RightHashJoinAntiMapsOne.cpp.o |
new | 1.37 MiB | +1.37 MiB |
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/HashJoin.cpp.o |
4.21 MiB | 5.58 MiB | +1.37 MiB (+32.45%) |
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/InnerHashJoinAnyMapsSet.cpp.o |
new | 1.21 MiB | +1.21 MiB |
src/CMakeFiles/dbms.dir/Storages/StorageJoin.cpp.o |
2.60 MiB | 2.67 MiB | +70.57 KiB (+2.65%) |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/JoinStep.cpp.o |
271.97 KiB | 312.87 KiB | +40.89 KiB (+15.04%) |
src/CMakeFiles/dbms.dir/Planner/Planner.cpp.o |
845.34 KiB | 881.89 KiB | +36.56 KiB (+4.32%) |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/JoinStepLogical.cpp.o |
1.05 MiB | 1.08 MiB | +23.85 KiB (+2.21%) |
src/CMakeFiles/dbms.dir/Processors/Transforms/JoiningTransform.cpp.o |
270.29 KiB | 291.81 KiB | +21.53 KiB (+7.96%) |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/skipDeduplicationAfterSetOperationJoin.c… |
new | 18.34 KiB | +18.34 KiB |
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
1915 translation units recompiled, 12038 s compile time in total, 1909 of them have a recent master baseline.
Translation units without a recent master baseline:
src/Interpreters/HashJoin/InnerHashJoinAnyMapsCount.cpp: 13.1 ssrc/Interpreters/HashJoin/LeftHashJoinAntiMapsCount.cpp: 13.0 ssrc/Interpreters/HashJoin/RightHashJoinAntiMapsCountWithRef.cpp: 13.0 ssrc/Interpreters/HashJoin/RightHashJoinAntiMapsOne.cpp: 11.7 ssrc/Interpreters/HashJoin/InnerHashJoinAnyMapsSet.cpp: 11.5 s
Symbol sizes
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
unsigned long DB::HashJoinMethods<(DB::JoinKind)0, (DB::JoinStrictness)2, DB::HashJoin::MapsTemplat… |
new | 151.50 KiB | +151.50 KiB |
programs/clickhouse-keeper |
unsigned long DB::HashJoinMethods<(DB::JoinKind)0, (DB::JoinStrictness)2, DB::HashJoin::MapsTemplat… |
new | 151.50 KiB | +151.50 KiB |
programs/clickhouse-keeper |
unsigned long DB::HashJoinMethods<(DB::JoinKind)2, (DB::JoinStrictness)6, DB::HashJoin::MapsTemplat… |
new | 147.95 KiB | +147.95 KiB |
programs/clickhouse |
unsigned long DB::HashJoinMethods<(DB::JoinKind)2, (DB::JoinStrictness)6, DB::HashJoin::MapsTemplat… |
new | 147.95 KiB | +147.95 KiB |
7873235 to
deccc87
Compare
c6e78e8 to
726bfc4
Compare
726bfc4 to
4f22308
Compare
Second part of: #115106
Follow-up to: #129089
Related: #120479
Related: #114550
This change builds on some of the ideas in #120479, thanks to @raimannma.
Execute
INTERSECT ALLandEXCEPT ALLas a hash join on all columns instead of the single-threadedIntersectOrExceptstep. This builds on theDISTINCTrewrite in #129089.How it works
The hash table stores a count of rows per key instead of the rows themselves.
INTERSECT ALLruns asINNER ANY. Each left row takes one copy of its key from the count, so a key that appears a times on the left and b times on the right is output min(a, b) times. The output columns are always taken from the probe side, so the hash table stays a count withoutRowRefs.EXCEPT ALLruns asLEFT ANTI. A left row is output only once the right copies of its key are used up, so the key is output a − b times.When the join order optimizer builds the left side,
EXCEPT ALLruns asRIGHT ANTI. Each cell keeps oneRowReftogether with the count, and the copies that were not taken are output after the probe. Only the blocks that hold such a row are kept.The probe streams lower the counts under one lock per bucket of the hash table, 256 in total, without atomics. Before that, the rows of a block are grouped by key, so all rows with one key take their copies with a single lookup, and a thread that finds a bucket locked continues with the next free one. The rows are grouped with a small hash table of at most 4096 keys per probe stream. A sample of 4096 rows decides whether the grouping pays off for the block. When it does not, a skip budget shared by all probe streams turns it off for the next rows.
JoinProbePreAggregationRowsCheckedandJoinProbePreAggregationGroupsshow how many rows were grouped and how many groups they formed.ll rows of a group are equal, so the result lists one row of each group as many times as the group is in the result, instead of keeping track of every row.
ScatteredBlock::filteraccepts such a list of repeated rows.The runtime filter is disabled for
EXCEPT ALLasLEFT ANTI, because a left row whose key is on the right is still output once the right copies are used up.When the join spills and must keep the left order,
INTERSECT ALLdoes not fall back toMergeJoin, which outputs one row per key instead of counting duplicates.With
extremes = 1, the extremes ofINTERSECT ALLandEXCEPT ALLare now computed on the result, instead of combining the extremes of the arms.Changes to the join code shared with other joins
IJoin::joinBlocktakes aJoinProbeContextwith the index of the probe stream, in the same way asJoinBuildContexton the build side. Every join type takes it, and only the joins on count maps use it.RuntimeFilterSkipBudgetis moved toCommon/RowsSkipBudget.hand shared with the grouping above.The matched rows of
EXPLAIN ANALYZEare counted from the list of output rows instead of the filter. For other joins both give the same number.Behavior shared with other joins
As a join, the set operations now share some limitations of joins.
With a very small spill threshold a spilling hash join can exceed the memory limit.
A
WHEREcondition over the result can be pushed into both arms, like any filter over a join, so an expression that throws for some rows can be evaluated on rows it did not see before.With
query_plan_optimize_join_order_algorithmset to onlydphypordpsize,EXCEPT ALLfails withFailed to find a valid join order.Performance, the new performance test
intersect_except_all_as_joinChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
INTERSECT ALLandEXCEPT ALLare now executed as a hash join, which makes them 2 to 10 times faster. The previous execution can be restored with the settingrewrite_intersect_except_all_to_join = 0.Workflow [PR]
Sync PR [sync-upstream/pr/129530]