Skip to content

Push join key filters into MergeTree index during recursive CTE evaluation - #97254

Closed
alexey-milovidov wants to merge 183 commits into
masterfrom
recursive-cte-join-index-optimization
Closed

alexey-milovidov wants to merge 183 commits into
masterfrom
recursive-cte-join-index-optimization

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

When a recursive CTE joins against a MergeTree table, each recursion step previously scanned the entire table, because the join condition (e.g. ON e.from_id = t.current_id) was not pushed into MergeTree's key condition.

This change analyzes the recursive query's join tree to find equi-join conditions between the CTE working table and real tables. Before each step it reads the join-key values from the working table and injects them as an IN (...) predicate directly into the WHERE clause of each recursive QueryNode that joins against the CTE (the original WHERE/HAVING/QUALIFY clauses are snapshotted at construction and restored after each step, so nothing accumulates across steps). The planner then lowers this predicate into ReadFromMergeTree's key condition. The injected set is bounded by the new setting recursive_cte_max_in_filter_cardinality, and injection fails closed to a plain scan whenever it could otherwise change results — when the generated set would exceed max_rows_in_set/max_bytes_in_set, cannot be materialized under max_memory_usage, or the IN predicate cannot be resolved for the join-key type. Parallel replicas are disabled for the recursive step queries to avoid stale cached GLOBAL JOIN tables returning incorrect results; the forcing mode allow_experimental_parallel_reading_from_replicas = 2 raises SUPPORT_IS_DISABLED for the recursive part rather than silently downgrading.

For a table with ~1M rows and 10 recursion steps, read_rows drops from ~10M to ~120.

Closes: #75026

Changelog category (leave one):

  • Performance Improvement

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

WITH RECURSIVE queries that use ON or comma equi-joins against MergeTree tables can now use the primary key index, reducing the number of rows read per recursion step. The optimization is controlled by the new setting recursive_cte_max_in_filter_cardinality.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

No separate documentation page is needed — this is a transparent performance improvement. The only user-visible addition is the setting recursive_cte_max_in_filter_cardinality, which is documented at the source level in src/Core/Settings.cpp.


Note

Medium Risk
Touches recursive CTE execution and query settings, and dynamically injects additional_table_filters, which could affect correctness/performance for some JOIN patterns despite being scoped to recursive steps.

Overview
Improves recursive CTE performance by detecting equi-join conditions between the CTE working table and real tables, then pushing join-key values into additional_table_filters (built as IN (...) predicates) on each recursive step so MergeTree reads can use the primary-key index; user-provided additional_table_filters are merged rather than overwritten.

Also disables parallel replicas for recursive CTE step queries to avoid incorrect results from reused cached GLOBAL JOIN tables, and adds a stateless test (03924_recursive_cte_join_index) asserting both correct output and low read_rows for explicit INNER JOIN and comma-join forms.

Written by Cursor Bugbot for commit 37f2618. This will update automatically on new commits. Configure here.


Workflow [PR]
Sync PR [sync-upstream/pr/97254]

…ation

When a recursive CTE joins against a MergeTree table, each recursion step
previously scanned the entire table because the join condition was not
pushed into the MergeTree key condition.

This change analyzes the recursive query's join tree to find equi-join
conditions between the CTE table and real tables. Before each recursive
step, it reads the join key values from the working (CTE) table and
injects them as `additional_table_filters` on the query context. The
existing planner infrastructure applies the filter as a `FilterStep`,
which the optimizer pushes into `ReadFromMergeTree`'s key condition.

For a table with ~1M rows and 10 recursion steps, this reduces
`read_rows` from ~10M to ~120.

Closes #75026

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a40ea32]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, parallel, 2/3) FAIL
04926_recursive_cte_merge_view_pruning FAIL cidb
Upgrade check (amd_release) FAIL
Cannot start clickhouse-server FAIL cidb
Check failed FAIL cidb
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) ERROR
Timeout FAIL cidb
AST fuzzer (amd_release, oracle) ERROR

AI Review

Summary

This PR adds recursive-CTE join-key pushdown so recursive joins against MergeTree tables can use the primary-key index, and it also adds a large preflight in RecursiveCTESource.cpp to disable or reject legacy parallel replicas when they would reuse stale GLOBAL JOIN state across recursion steps. The pushdown logic itself is in much better shape than earlier revisions, but the new parallel-replica preflight still diverges from the planner's actual outer-join eligibility rules and now rejects some recursive queries that the normal planner would execute plainly.

Findings

❌ Blockers

  • [src/Processors/Sources/RecursiveCTESource.cpp:578-613] plannerDisablesParallelReplicasForJoinTreeShape only mirrors the VIEW-specific and silent-disable subsets of allowParallelReplicasForJoinTree(), but it never mirrors the planner's general "driver leaf must itself be eligible" rule. For INNER / LEFT, PlannerJoinTree only considers the leftmost table expression; for RIGHT JOIN, it additionally requires both sides to pass parallelReplicasEnabledForStorage(). Because mayEngageParallelReplicas() still treats any eligible leaf as sufficient, recursive queries such as FROM rec AS t INNER JOIN edges AS e ... or FROM rec AS t RIGHT JOIN edges AS e ... are now forced into SUPPORT_IS_DISABLED even though the real planner would run them without parallel replicas. The added right_join_local_pr_throw regression also bakes in that wrong behavior.
Final Verdict

Not ready. The recursive-step parallel-replica guard still rejects valid join shapes because its preflight is broader than the planner it is supposed to mirror.

LLVM Coverage Report

Measured on commit a40ea32.

Metric Baseline Current Δ
Lines 88.60% 88.60% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 80.90% 80.90% +0.00%

Changed lines: Changed C/C++ lines covered: 477/597 (79.90%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Feb 18, 2026
@alexey-milovidov
alexey-milovidov marked this pull request as draft February 19, 2026 08:21
When parallel replicas is enabled, JOINs are rewritten to GLOBAL JOINs
and the right-side subquery is materialized into a cached external table
keyed by tree hash. Since the recursive CTE temporary table has the same
tree structure across steps (only the data changes), the hash stays
identical and stale cached data is reused, producing wrong results.

Also fix the test to use a fixed `index_granularity` so the `read_rows`
threshold check is stable across randomized MergeTree settings.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Fix for ParallelReplicas CI failure

Root cause: When parallel replicas is enabled, JOINs are rewritten to GLOBAL JOINs by rewriteJoinToGlobalJoin. The right-side subquery (the CTE temporary table) is then materialized into a cached external table by executeSubqueryNode in buildQueryTreeForShard.cpp, using the subquery's tree hash as the cache key (_data_{hash}).

Since the recursive CTE temporary table has the same tree structure across all recursive steps (only the data changes between steps), the hash stays identical. On step 2+, the cache returns stale data from step 1, causing the JOIN to find no matches and the recursion to terminate early (producing 1, 2 instead of 1, 2, ..., 10).

Fix: Disable parallel replicas for the recursive CTE step queries by setting allow_experimental_parallel_reading_from_replicas = 0 on the recursive query context. This prevents the GLOBAL JOIN rewrite entirely for recursive steps, while still allowing the additional_table_filters optimization to work. The non-recursive (initial) step is unaffected since its query node has its own context.

Also fixed index_granularity in the test to 8192 so the read_rows < 100000 threshold is stable when the test runner randomizes MergeTree settings.

Address review feedback: instead of overwriting the `additional_table_filters`
setting on each recursive step, save the original user-specified value at
construction time and merge CTE-derived filters with it. For tables that
appear in both, filters are combined with AND. User-specified filters for
unrelated tables are preserved.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@asad-awadia

Copy link
Copy Markdown

Really interested in this optimization. I am traversing trees using recursive CTEs and it never finishes just continues processing rows and chewing up memory [300 million rows in the table].

Any idea when this might land? and will this be used if the join condition is on a column that is not in the primary/order-by key?

@alexey-milovidov

@alexey-milovidov
alexey-milovidov marked this pull request as ready for review March 5, 2026 22:19
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@asad-awadia, a high chance it will be in 26.3 LTS.

and will this be used if the join condition is on a column that is not in the primary/order-by key?

It's likely it will be used for any indices, but let's see...

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The implementation is a bit wacky - need more thoughts in review...

@alexey-milovidov
alexey-milovidov requested a review from novikd March 5, 2026 22:22

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@geldot

geldot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

The implementation is a bit wacky - need more thoughts in review...

My sense is that the approach is obvious technical debt but it's not user-facing so could be improved later on the go. I think it'd be OK to land something like this but there should be a concrete plan to replace it with a dynamic planner stage, so it ends up sharing implementation with existing parts of the analyzer. I think the stage would benefit potential MV optimizations, distributed queries, dynamic push down to other engines etc., which are all variations on partially runtime constructed execution plans.

alexey-milovidov and others added 2 commits March 30, 2026 07:51
- Deduplicate join key values using `std::set` before building the IN
  filter expression (review thread by cursor)
- Add `MAX_IN_FILTER_CARDINALITY` (10000) limit: if the working table
  has more distinct values than this, skip the optimization for that
  step and fall back to unfiltered scans, avoiding unbounded SQL
  expressions that could exceed `max_query_size` (review thread by
  clickhouse-gh)
- Return `std::nullopt` from `readColumnValuesFromMemoryStorage` to
  signal cardinality overflow, handled gracefully in
  `buildAdditionalTableFiltersForRecursiveStep`

Note: the concern about overwriting user-specified
`additional_table_filters` (review thread by geldot) was already
addressed — `original_additional_table_filters` is saved at construction
time and merged on each step via `buildAdditionalTableFiltersForRecursiveStep`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov and others added 2 commits March 30, 2026 11:54
- Remove redundant `static` from `MAX_IN_FILTER_CARDINALITY` inside
  anonymous namespace (fixes `readability-static-definition-in-anonymous-namespace`
  clang-tidy error in arm_tidy build).

- Match user-specified `additional_table_filters` by both full name
  (`db.table`) and short name (`table` when current database matches),
  mirroring the matching logic in `PlannerJoinTree::buildAdditionalFiltersIfNeeded`.
  Previously, user filters keyed by short table name would not be found
  during merge and could be silently shadowed by the CTE-generated filter,
  since `PlannerJoinTree` takes the first matching entry and breaks.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…index-optimization

# Conflicts:
#	ci/jobs/copilot_review_job.py
#	ci/jobs/scripts/generate_diff_coverage_report.sh
#	ci/jobs/sqlancer_job.sh
#	ci/praktika/cidb.py
#	ci/tests/test_functional_tests_results.py
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParser.cpp
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParser.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParser.interp
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserBaseListener.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserBaseVisitor.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserListener.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserVisitor.h
#	contrib/aws-c-http
#	docker/keeper/Dockerfile
#	docker/server/Dockerfile.alpine
#	programs/client/Client.h
#	programs/server/webterminal.html
#	src/AggregateFunctions/AggregateFunctionSequenceMatch.cpp
#	src/AggregateFunctions/TimeSeries/AggregateFunctionLast2Samples.h
#	src/AggregateFunctions/TimeSeries/AggregateFunctionTimeSeriesGroupArray.cpp
#	src/Analyzer/Passes/CrossToInnerJoinPass.cpp
#	src/Backups/BackupFactory.h
#	src/Backups/BackupImpl.h
#	src/Backups/BackupSettings.cpp
#	src/Backups/BackupSettings.h
#	src/Backups/IBackup.h
#	src/Client/BuzzHouse/AST/SQLProtoStr.cpp
#	src/Client/BuzzHouse/Generator/RandomGenerator.cpp
#	src/Client/BuzzHouse/Generator/RandomGenerator.h
#	src/Client/ClientBase.h
#	src/Columns/ColumnDynamic.h
#	src/Columns/IColumnUnique.h
#	src/Common/ColumnsHashing.h
#	src/Common/ColumnsHashingImpl.h
#	src/Common/Fiber.h
#	src/Common/HashTable/TwoLevelHashTable.h
#	src/Common/OpenTelemetryTraceContext.cpp
#	src/Common/PoolBase.h
#	src/Common/ThreadStatus.h
#	src/Compression/CompressionFactory.h
#	src/Coordination/KeeperStateMachine.h
#	src/Coordination/tests/gtest_coordination_snapshot.cpp
#	src/Core/PostgreSQL/PoolWithFailover.cpp
#	src/Core/PostgreSQLProtocol.h
#	src/DataTypes/DataTypeAggregateFunction.h
#	src/DataTypes/Serializations/SerializationJSON.cpp
#	src/Databases/MySQL/DatabaseMySQL.cpp
#	src/Disks/DiskObjectStorage/DiskObjectStorage.cpp
#	src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp
#	src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.h
#	src/Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/AzureBlobStorageCommon.cpp
#	src/Disks/DiskObjectStorage/ObjectStorages/IObjectStorage.h
#	src/Functions/CastOverloadResolver.cpp
#	src/Functions/FunctionFQDN.cpp
#	src/Functions/FunctionShowCertificate.cpp
#	src/Functions/FunctionStringOrArrayToT.h
#	src/Functions/FunctionsJSON.cpp
#	src/Functions/FunctionsStringDistance.cpp
#	src/Functions/FunctionsTransactionCounters.cpp
#	src/Functions/TimeSeries/timeSeriesThrowDuplicateSeriesIf.cpp
#	src/Functions/UTCTimestampTransform.cpp
#	src/Functions/aiEmbed.cpp
#	src/Functions/array/arrayJoin.cpp
#	src/Functions/castOrDefault.cpp
#	src/Functions/filesystem.cpp
#	src/Functions/formatRow.cpp
#	src/Functions/match.cpp
#	src/Functions/queryID.cpp
#	src/Functions/rand.cpp
#	src/Functions/rand64.cpp
#	src/IO/ReadBufferFromFileDescriptor.cpp
#	src/IO/S3/Client.cpp
#	src/Interpreters/Access/InterpreterShowCreateAccessEntityQuery.cpp
#	src/Interpreters/AggregationMethod.h
#	src/Interpreters/AsynchronousMetricLog.cpp
#	src/Interpreters/CancellationChecker.cpp
#	src/Interpreters/ClusterFunctionReadTask.h
#	src/Interpreters/HashJoin/KeyGetter.h
#	src/Interpreters/InterpreterHypotheticalIndexQuery.cpp
#	src/Interpreters/MetricLog.cpp
#	src/Interpreters/ProcessList.cpp
#	src/Interpreters/SpillingHashJoin.cpp
#	src/Interpreters/SpillingHashJoin.h
#	src/Parsers/Access/ParserCreateQuotaQuery.cpp
#	src/Parsers/Access/ParserCreateUserQuery.cpp
#	src/Parsers/ExpressionElementParsers.cpp
#	src/Parsers/ExpressionListParsers.cpp
#	src/Parsers/Kusto/ParserKQLOperators.cpp
#	src/Parsers/Lexer.cpp
#	src/Parsers/ParserAlterQuery.cpp
#	src/Parsers/ParserCreateFunctionQuery.cpp
#	src/Parsers/ParserCreateQuery.cpp
#	src/Parsers/ParserExplainQuery.cpp
#	src/Parsers/ParserInsertQuery.cpp
#	src/Parsers/ParserOptimizeQuery.cpp
#	src/Parsers/ParserQueryWithOutput.cpp
#	src/Parsers/ParserSelectQuery.cpp
#	src/Parsers/ParserSelectWithUnionQuery.cpp
#	src/Parsers/ParserSetQuery.cpp
#	src/Parsers/ParserSystemQuery.cpp
#	src/Parsers/ParserTablesInSelectQuery.cpp
#	src/Processors/Executors/PipelineExecutor.cpp
#	src/Processors/Formats/Impl/MsgPackRowInputFormat.cpp
#	src/Processors/Formats/Impl/NativeORCBlockInputFormat.h
#	src/Processors/Formats/Impl/ProtobufListInputFormat.cpp
#	src/Processors/IProcessor.h
#	src/Processors/QueryPlan/AggregatingStep.cpp
#	src/Processors/QueryPlan/ArrayJoinStep.h
#	src/Processors/QueryPlan/CreatingSetsStep.cpp
#	src/Processors/QueryPlan/CreatingSetsStep.h
#	src/Processors/QueryPlan/ExpressionStep.cpp
#	src/Processors/QueryPlan/Optimizations/optimizeLazyMaterialization.cpp
#	src/Processors/QueryPlan/Optimizations/optimizeReadInOrder.h
#	src/Processors/QueryPlan/Optimizations/topKThroughJoin.cpp
#	src/Processors/QueryPlan/ReadFromRemote.cpp
#	src/Processors/Sources/RecursiveCTESource.cpp
#	src/Processors/Sources/ShellCommandSource.cpp
#	src/Processors/Transforms/DistinctTransform.cpp
#	src/Processors/Transforms/FilterTransform.h
#	src/Processors/tests/gtest_update_pipeline.cpp
#	src/QueryPipeline/BlockIO.h
#	src/QueryPipeline/Pipe.h
#	src/QueryPipeline/QueryPipelineBuilder.h
#	src/QueryPipeline/RemoteQueryExecutorReadContext.cpp
#	src/Server/DistributedQuery/StreamingExchangeSource.cpp
#	src/Server/HTTPHandlerFactory.h
#	src/Storages/KVStorageUtils.cpp
#	src/Storages/MergeTree/LoadedMergeTreeDataPartInfoForReader.h
#	src/Storages/MergeTree/MergeTask.h
#	src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp
#	src/Storages/MergeTree/MergeTreeDataWriter.h
#	src/Storages/MergeTree/MergeTreeIndexMinMax.h
#	src/Storages/MergeTree/MergeTreeIndexReader.cpp
#	src/Storages/MergeTree/MergeTreeIndicesSerialization.h
#	src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp
#	src/Storages/MergeTree/Streaming/CursorUtils.cpp
#	src/Storages/MergeTree/Streaming/CursorUtils.h
#	src/Storages/MergeTree/Streaming/MergeTreeBoundsSubscription.cpp
#	src/Storages/MergeTree/Streaming/MergeTreeBoundsSubscription.h
#	src/Storages/MergeTree/Streaming/MergeTreeCommitOrderSequentialSource.cpp
#	src/Storages/MergeTree/Streaming/MergeTreeCommitOrderSequentialSource.h
#	src/Storages/MergeTree/Streaming/StreamingChunkCursor.cpp
#	src/Storages/MergeTree/Streaming/StreamingChunkCursor.h
#	src/Storages/MergeTree/Streaming/SubscriptionEnrichment.cpp
#	src/Storages/MergeTree/Streaming/SubscriptionEnrichment.h
#	src/Storages/MergeTree/Streaming/tests/gtest_bounds_subscription.cpp
#	src/Storages/MergeTree/TextIndexUtils.h
#	src/Storages/MergeTree/WhatIfIndexEstimator.cpp
#	src/Storages/MergeTree/WhatIfIndexEstimator.h
#	src/Storages/NATS/NATS_fwd.h
#	src/Storages/ObjectStorage/DataLakes/DataLakeStorageSettings.cpp
#	src/Storages/ObjectStorage/DataLakes/DataLakeStorageSettings.h
#	src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.h
#	src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp
#	src/Storages/ObjectStorage/IObjectIterator.h
#	src/Storages/ObjectStorage/StorageObjectStorage.h
#	src/Storages/ObjectStorage/StorageObjectStorageConfiguration.h
#	src/Storages/ObjectStorage/StorageObjectStorageSink.cpp
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueMetadata.cpp
#	src/Storages/PostgreSQL/MaterializedPostgreSQLConsumer.cpp
#	src/Storages/Statistics/tests/gtest_stats.cpp
#	src/Storages/StorageAlias.h
#	src/Storages/StorageBuffer.h
#	src/Storages/StorageMemory.h
#	src/Storages/StorageMerge.cpp
#	src/Storages/StorageMergeTreeTextIndex.cpp
#	src/Storages/StorageStripeLog.cpp
#	src/Storages/StorageTimeSeries.cpp
#	src/Storages/System/StorageSystemMutations.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/NodeEvaluationRangeGetter.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorAnd.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorOr.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorUnless.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applySimpleBinaryOperator.cpp
#	tests/clickhouse-test
#	tests/integration/test_ai_functions/test.py
#	tests/integration/test_broken_projections/test.py
#	tests/integration/test_prometheus_protocols/test_insert_select.py
#	tests/integration/test_replicated_users/test.py
#	tests/integration/test_storage_azure_blob_storage/test.py
#	tests/integration/test_storage_rabbitmq/test.py
#	tests/integration/test_storage_s3_queue/test_0.py
#	tests/integration/test_text_index_upgrade/test.py
#	tests/performance/README.md
#	tests/performance/scripts/README.md
#	tests/queries/0_stateless/00826_cross_to_inner_join.oldanalyzer.reference
#	tests/queries/0_stateless/00849_multiple_comma_join_2.reference
#	tests/queries/0_stateless/00908_analyze_query.oldanalyzer.reference
#	tests/queries/0_stateless/00940_order_by_read_in_order_query_plan.reference
#	tests/queries/0_stateless/01029_early_constant_folding.oldanalyzer.reference
#	tests/queries/0_stateless/01083_cross_to_inner_with_like.oldanalyzer.reference
#	tests/queries/0_stateless/01323_redundant_functions_in_order_by.oldanalyzer.reference
#	tests/queries/0_stateless/01372_wrong_order_by_removal.oldanalyzer.reference
#	tests/queries/0_stateless/01376_GROUP_BY_injective_elimination_dictGet.oldanalyzer.reference
#	tests/queries/0_stateless/01415_table_function_view.oldanalyzer.reference
#	tests/queries/0_stateless/01470_columns_transformers2.oldanalyzer.reference
#	tests/queries/0_stateless/01471_with_format.oldanalyzer.reference
#	tests/queries/0_stateless/01495_subqueries_in_with_statement_4.oldanalyzer.reference
#	tests/queries/0_stateless/01582_move_to_prewhere_compact_parts.sql
#	tests/queries/0_stateless/01622_constraints_simple_optimization.oldanalyzer.reference
#	tests/queries/0_stateless/01622_constraints_where_optimization.oldanalyzer.reference
#	tests/queries/0_stateless/01623_constraints_column_swap.oldanalyzer.reference
#	tests/queries/0_stateless/01625_constraints_index_append.reference
#	tests/queries/0_stateless/01655_plan_optimizations.reference
#	tests/queries/0_stateless/01655_plan_optimizations.sh
#	tests/queries/0_stateless/01706_optimize_normalize_count_variants.oldanalyzer.reference
#	tests/queries/0_stateless/01732_explain_syntax_union_query.oldanalyzer.reference
#	tests/queries/0_stateless/01883_with_grouping_sets.oldanalyzer.reference
#	tests/queries/0_stateless/02000_join_on_const.sql
#	tests/queries/0_stateless/02004_intersect_except_distinct_operators.oldanalyzer.reference
#	tests/queries/0_stateless/02004_intersect_except_operators.oldanalyzer.reference
#	tests/queries/0_stateless/02117_show_create_table_system.reference
#	tests/queries/0_stateless/02125_constant_if_condition_and_not_existing_column.oldanalyzer.reference
#	tests/queries/0_stateless/02220_array_join_format.oldanalyzer.reference
#	tests/queries/0_stateless/02226_analyzer_or_like_combine.oldanalyzer.reference
#	tests/queries/0_stateless/02253_empty_part_checksums.sh
#	tests/queries/0_stateless/02315_replace_multiif_to_if.oldanalyzer.reference
#	tests/queries/0_stateless/02346_text_index_direct_read.sql
#	tests/queries/0_stateless/02346_text_index_tokenizer_partially_materialized.sql
#	tests/queries/0_stateless/02353_order_by_tuple.reference
#	tests/queries/0_stateless/02377_executable_function_settings.sql
#	tests/queries/0_stateless/02428_parameterized_view.oldanalyzer.reference
#	tests/queries/0_stateless/02428_parameterized_view.sh
#	tests/queries/0_stateless/02477_logical_expressions_optimizer_low_cardinality.oldanalyzer.reference
#	tests/queries/0_stateless/02496_remove_redundant_sorting.sh
#	tests/queries/0_stateless/02500_remove_redundant_distinct.reference
#	tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.reference
#	tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.sh
#	tests/queries/0_stateless/02516_join_with_totals_and_subquery_bug.reference
#	tests/queries/0_stateless/02554_fix_grouping_sets_predicate_push_down.oldanalyzer.reference
#	tests/queries/0_stateless/02554_fix_grouping_sets_predicate_push_down.reference
#	tests/queries/0_stateless/02785_date_predicate_optimizations_ast_query_tree_rewrite.oldanalyzer.reference
#	tests/queries/0_stateless/02800_clickhouse_local_default_settings.reference
#	tests/queries/0_stateless/02815_join_algorithm_setting.sql
#	tests/queries/0_stateless/02864_statistics_ddl.sql
#	tests/queries/0_stateless/02868_distinct_to_count_optimization.reference
#	tests/queries/0_stateless/03001_matview_columns_after_modify_query.sh
#	tests/queries/0_stateless/03071_fix_short_circuit_logic.sql
#	tests/queries/0_stateless/03161_cnf_reduction.reference
#	tests/queries/0_stateless/03381_query_result_cache_old_analyzer.sql
#	tests/queries/0_stateless/03393_non_constant_second_argument_for_in.reference
#	tests/queries/0_stateless/03393_non_constant_second_argument_for_in.sql
#	tests/queries/0_stateless/03444_explain_asterisk.reference
#	tests/queries/0_stateless/03560_parallel_replicas_memory_bound_merging_projection.reference
#	tests/queries/0_stateless/03628_subcolumns_of_columns_with_dot_in_name.sql
#	tests/queries/0_stateless/03707_analyzer_convert_outer_any_to_inner.reference
#	tests/queries/0_stateless/03724_filter_assume_not_null_materialize.sql
#	tests/queries/0_stateless/03773_deterministic_functions_key_condition_explain.reference
#	tests/queries/0_stateless/03779_time_series_tags_functions.reference
#	tests/queries/0_stateless/03779_time_series_tags_functions.sql
#	tests/queries/0_stateless/03988_setting_use_partition_pruning.sql
#	tests/queries/0_stateless/04019_pipeline_stuck_sort_overflow.sql
#	tests/queries/0_stateless/04033_except_transformer_with_alias.sql
#	tests/queries/0_stateless/04093_text_index_separate_analysis.sql
#	tests/queries/0_stateless/04098_row_policy_disjunction_optimization.reference
#	tests/queries/0_stateless/04098_row_policy_disjunction_optimization.sql
#	tests/queries/0_stateless/04105_explain_syntax_parameterized_view.oldanalyzer.reference
#	tests/queries/0_stateless/04105_explain_syntax_parameterized_view.sql
#	tests/queries/0_stateless/04105_view_positional_args_via_local_plan.sh
#	tests/queries/0_stateless/04201_inverse_dictionary_lookup_edge_cases.reference
#	tests/queries/0_stateless/04207_pr_additional_filters.reference
#	tests/queries/0_stateless/04207_pr_additional_filters.sql
#	tests/queries/0_stateless/04209_statistics_retry_load.reference
#	tests/queries/0_stateless/04209_top_k_through_join_read_in_order_gate.reference
#	tests/queries/0_stateless/04209_top_k_through_join_read_in_order_gate.sql
#	tests/queries/0_stateless/04234_top_k_through_join_final_desc_gate.sql
#	tests/queries/0_stateless/04280_udf_normalizer_dangling_source_columns.sql
#	tests/queries/0_stateless/04320_distributed_plan_read_rejects.sql
#	tests/queries/0_stateless/04323_text_index_marks_empty_part.sh
#	tests/queries/0_stateless/04335_low_cardinality_mixed_key_join.sql
#	tests/queries/0_stateless/04338_analyzer_unknown_table_cross_database_hint.reference
#	tests/queries/0_stateless/04338_analyzer_unknown_table_cross_database_hint.sh
#	tests/stress/keeper/framework/core/cluster.py
#	utils/list-versions/version_date.tsv
…light

Addresses the two open review findings on `plannerDisablesParallelReplicasForJoinTreeShape`:

* A `StorageView` reached through a table function (`view(...)`,
  `viewIfPermitted(...)`) was not recognized by the leftmost-view escape, which only
  looked at `TableNode`. `allowParallelReplicasForJoinTree` decides a leftmost
  `TableFunctionNode` with `parallelReplicasEnabledForStorage`, which accepts a view
  only when it unwraps to an eligible `MergeTree` table - so a `view(...)` over a
  `Distributed` table leaves the outer join tree ineligible exactly like a plain view
  table, and the forced mode must not reject such a step. The new
  `parallelReplicasEnabledForViewStorage` mirrors that rule, so a view that *does*
  unwrap to an eligible `MergeTree` table still reports a genuine engagement.

* A single `FULL JOIN` was not covered: the n-way rules only suppress `FULL` when it
  appears in a join stack, while `allowParallelReplicasForJoinTree` never lets any join
  kind other than an `ALL INNER`, `LEFT` or `RIGHT` join drive parallel replicas. The
  top-level check now mirrors that directly, which also covers `COMMA` and `PASTE`
  joins and subsumes the previous non-`ALL` `INNER JOIN` special case.

Both are covered by new forced-mode cases in `04489_recursive_cte_join_index`
(`full_join_local_pr`, `view_fn_left_dist_pr`).

The same test was failing reproducibly in CI (38 jobs) on the previous head, and this
commit fixes those failures too:

* The `if (!engagement.any()) return;` shortcut added in the previous pass left
  `allow_experimental_parallel_reading_from_replicas = 2` in place for every step whose
  engagement is zero. A recursive CTE whose *non-recursive* part reads a table then
  really does use parallel replicas for that ordinary read, which needs a configured
  cluster - hence `CLUSTER_DOESNT_EXIST` in the 31 jobs that run with the default
  (empty) `cluster_for_parallel_replicas`. The preflight disables the setting again, and
  the two cases whose seed reads a table (`traverse_pr_cross_join`,
  `traverse_pr_any_inner_join`) name the cluster like the plan-based cases already do.

* `view_pr` / `view_pr_throw` join the view on the *right* side, so the leftmost-view
  gate does not apply to them: their view inner query really can engage parallel
  replicas and the forced mode must keep failing closed. Their expectations are restored
  to `SUPPORT_IS_DISABLED` (they were flipped to success in the previous pass, which is
  what made 7 jobs fail), and the query-log assertion that they used parallel replicas
  is dropped with them.

* The plan-based query-log assertion now covers only the forced mode. The best-effort
  mode (`= 1`) is free to decide from the plan that parallel replicas are not worth it
  for the tiny recursive steps of `plan_based_joined_pr`, which it does.

* The `float_walk_auto` case is removed: with `join_algorithm = 'auto'` the switcher does
  not fall back to `partial_merge` in this shape at any `max_bytes_in_join` /
  `max_rows_in_join` value - it either throws `SET_SIZE_LIMIT_EXCEEDED` or stays on the
  hash path - so the case could not test what it intended. `float_walk_pm` and
  `float_walk_ppm` keep the value-comparing coverage.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Updated the branch with current master (merge 478a834dc75f, the branch was 3310 commits behind and GitHub reported it as CONFLICTING) and pushed the review fixes in 93a525de362a.

The merge was a criss-cross one (two merge bases), so the artificial conflict set was 274 files while the PR touches 12: every conflicted file outside the PR set was taken from master verbatim, the two overlapping files were re-merged against the real base, and the final git diff --cached origin/master was verified byte-identical to the pre-merge <base>..HEAD diff (12 files), so the result is master plus this PR exactly.

Both open review threads are addressed (replies on discussion_r3860524415 and discussion_r3860525744, both resolved):

  • the leftmost-view escape now covers a StorageView behind a table function, mirroring parallelReplicasEnabledForStorage rather than escaping unconditionally, and
  • the top-level join-kind check now mirrors allowParallelReplicasForJoinTree directly, which covers a single FULL JOIN.

The same commit also fixes the CI red on the previous head, where all 45 failures were this PR's own tests (04489_recursive_cte_join_index in 38 jobs, 04926_recursive_cte_merge_view_pruning in 1):

  • 31 jobs failed with CLUSTER_DOESNT_EXIST. The if (!engagement.any()) return; shortcut from the previous pass left allow_experimental_parallel_reading_from_replicas = 2 in place for steps with zero engagement, and the non-recursive part of traverse_pr_cross_join reads a table — that ordinary read really does use parallel replicas and needs a cluster, which the default (empty) cluster_for_parallel_replicas does not provide. The preflight disables the setting again, and the two cases whose seed reads a table now name the cluster like the plan-based cases already do.
  • 7 jobs failed with SUPPORT_IS_DISABLED on view_pr. That query joins the view on the right side, so the leftmost-view gate never applied to it: its inner view query can engage parallel replicas and the forced mode must keep failing closed. view_pr / view_pr_throw are back to expecting SUPPORT_IS_DISABLED.
  • The plan-based query-log assertion now covers only the forced mode — the best-effort mode is free to decide from the plan that parallel replicas are not worth it for those tiny steps, and it does. The float_walk_auto case is removed: with join_algorithm = 'auto' the switcher never reaches its partial_merge fallback in that shape at any limit value, so the case could not test its intent; float_walk_pm and float_walk_ppm keep that coverage.

Verified locally on the merged branch: 04489_recursive_cte_join_index and 04926_recursive_cte_merge_view_pruning pass with fixed settings and across randomized runs, both with a configured cluster_for_parallel_replicas and with the default empty one (the configuration that was failing in CI).

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Updated the branch (was 917 commits behind, GitHub showed UNKNOWN mergeability):

  • Merged master (8b1aad536d80). The plain git merge exploded into ~90 spurious conflicts in files this PR never touched — git merge-base --all returned two bases (criss-cross history, 2026-08-26 + 2026-05-29), which poisons the ort virtual-ancestor merge. Redid the merge single-base via git merge-tree --write-tree --merge-base=887b93e16db9 — fully clean, and the net diff versus master is exactly the PR's own 12 files.
  • Fixed the Style check failure settings_changes_history (the only real red on 93a525de; everything else was DROPPED): master moved on to 26.9, so the recursive_cte_max_in_filter_cardinality history entry sat in the already-released 26.8 block. Moved it to the 26.9 block (2d2d38b09138).

RecursiveCTESource.cpp, Settings.cpp, SettingsChangesHistory.cpp, and findParallelReplicasQuery.cpp all compile clean against the merged tree. 0 unresolved review threads. Waiting for a fresh CI run on 2d2d38b09138.

alexey-milovidov and others added 3 commits August 30, 2026 18:38
…able engages parallel replicas

The `TableFunctionNode` arm of the parallel-replica engagement walk only checked the
inner query of a `StorageView`-backed table function, but `StorageView::getViewContext`
disables parallel replicas in the inner context exactly when the outer planner can unwrap
the leftmost table function to an eligible `MergeTree` table
(`parallel_replicas_allow_view_over_mergetree`), so such a `view(...)` looked unable to
engage them and the forcing mode was silently downgraded for a step the planner would
really parallelize. Mirror the `TableNode` branch: judge the storage with
`parallelReplicasEnabledForViewStorage` (the planner decides a table-function leaf with
`parallelReplicasEnabledForStorage`) and count the outer read, merging the inner-query
engagement only for the cases the outer rule does not cover.

Two regression cases in `04489_recursive_cte_join_index`: the forcing mode fails closed
with the unwrapping on, and keeps running plainly with it off.

Co-Authored-By: Claude Fable 5 <[email protected]>
…flight

Master now prunes a `Merge` child by `_table` / `_database` filters only when the child
does not read its data from other tables (`IStorage::readsFromOtherTables`): the rows of
a `Distributed` / `Alias` / `Buffer` / nested `Merge` child are stamped with the name of
the table that actually produced them, so such a child is always read and the predicate
filters its rows. The recursive-step preflight still assumed any child could be pruned
away, treating a `Merge` that mixes a local child with a `Distributed` one as unable to
engage parallel replicas — but the `ClusterProxy`-served read of the `Distributed` child
now always happens, so the forcing mode must fail closed for it, exactly as for an
all-remote `Merge`.

The engagement of a non-prunable child is now unconditional; the prunable subset keeps
the previous rules (all-eligible or nothing, the estimate-subject flavor wins a mixed
prunable set, and the read count stays ambiguous only when a prunable child contributes
to it). The `merge_mixed_local_pr` case in `04489_recursive_cte_join_index` asserts the
new fail-closed behavior; its old expectation also stopped holding data-wise, since the
`_table = 'edges'` filter no longer excludes the `Distributed` child's rows (they are
stamped `edges` too) and the plain read returned doubled rows.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Status (2026-08-30 pass): pushed master merge 6b541af33115 + two fixes, head 2d2d38b09138 → a40ea32b5759.

  1. Merged master (1524 commits behind, GitHub showed CONFLICTING; the local merge was clean with a single merge base). Now MERGEABLE, 0 unresolved threads.
  2. Fixed the view(...)-over-MergeTree force-or-throw gap (7fd18f708261, review thread + AI-review Major): the TableFunctionNode arm of the engagement walk now mirrors the TableNode branch via parallelReplicasEnabledForViewStorage, so a leftmost view(SELECT * FROM mt) with parallel_replicas_allow_view_over_mergetree = 1 fails closed under the forcing mode instead of silently downgrading. Two regression cases added to 04489_recursive_cte_join_index (throw with the unwrapping on, plain run with it off).
  3. Adapted the Merge preflight to master's new child-pruning rule (a40ea32b5759): since 81cfe601f299, a Merge child that reads from other tables (Distributed/Alias/Buffer/nested Merge) is never pruned by _table/_database filters and stamps its rows with the producing table's name. The preflight now treats such children's engagement as unconditional, so a Merge mixing a local child with a Distributed one fails closed under the forcing mode; merge_mixed_local_pr asserts the new behavior (its old expectation had also broken data-wise on master — the _table = 'edges' filter no longer excludes the Distributed child's rows, and the plain read returned 9217 instead of 55).
  4. Declined the rewrite_context early-return requested by the remaining AI-review Major, with evidence on the thread: the exact if (!engagement.any()) return; shortcut was already tried and reverted in 93a525de362a after failing reproducibly in 38 CI jobs.

Verified locally: 04489_recursive_cte_join_index green 3× (1 no-random + 2 randomized) and all 26 *recursive_cte* tests green against a private server built from this head.

Next: fresh CI on a40ea32b5759 → AI re-verdict → human review/approve → un-draft → human merge.

Comment on lines +578 to +613
/// `allowParallelReplicasForJoinTree` rejects an ordinary `VIEW` as the
/// leftmost join-table expression. `StorageView::readImpl` can still use
/// parallel replicas for the view's inner query, but that query does not
/// reference the recursive working table, so it cannot use the stale
/// `GLOBAL JOIN` table that this guard prevents.
const auto & left_table_expression = join_node->getLeftTableExpressionNode();
if (const auto * left_table = left_table_expression->as<TableNode>();
left_table && left_table->getStorage()->isView())
return true;

/// The same escape for a `StorageView` reached through a table function
/// (`view(...)`, `viewIfPermitted(...)`): `allowParallelReplicasForJoinTree`
/// does not apply its unconditional `TableNode` view rejection to it, but
/// falls back to the storage-level rule for the leftmost table expression,
/// which is `parallelReplicasEnabledForStorage`. That rule accepts a view
/// only when it unwraps to an eligible `MergeTree` table, so a `view(...)`
/// over a `Distributed` table (or over a `MergeTree` table the settings do
/// not allow) leaves the outer join tree ineligible, exactly like a plain
/// view table. A view that does unwrap to an eligible `MergeTree` table
/// stays eligible here, so a genuine engagement is still reported.
if (const auto * left_table_function = left_table_expression->as<TableFunctionNode>())
{
if (const auto * view = typeid_cast<const StorageView *>(left_table_function->getStorage().get());
view && !parallelReplicasEnabledForViewStorage(*view, context))
return true;
}

/// `allowParallelReplicasForJoinTree` only ever allows an `ALL INNER`, a
/// `LEFT` or a `RIGHT` join to drive parallel replicas; every other join
/// kind — in particular a single `FULL JOIN`, which the n-way rules below
/// do not cover — falls through to its final `return false`.
const auto join_kind = join_node->getKind();
if (!(join_kind == JoinKind::Inner && join_node->getStrictness() == JoinStrictness::All)
&& join_kind != JoinKind::Left
&& join_kind != JoinKind::Right)
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

plannerDisablesParallelReplicasForJoinTreeShape still does not mirror PlannerJoinTree::allowParallelReplicasForJoinTree() closely enough. For INNER / LEFT, the planner only lets the leftmost table expression drive parallel replicas (PlannerJoinTree.cpp:1584-1599), and for RIGHT JOIN it also requires both sides to pass parallelReplicasEnabledForStorage() (PlannerJoinTree.cpp:1602-1624). Here we only special-case VIEWs plus a few silent-disable shapes, so any eligible leaf on either side is still enough for mayEngageParallelReplicas() to mark the recursive context as engaged.

That produces false SUPPORT_IS_DISABLED rejections for queries the normal planner runs plainly, for example WITH RECURSIVE ... SELECT ... FROM rec AS t INNER JOIN edges AS e ON e.from_id = t.n or ... FROM rec AS t RIGHT JOIN edges AS e ...: the left side is the working-table StorageMemory, so the outer join can never be a parallel-replica candidate, but this preflight still sees edges and throws. The new right_join_local_pr_throw case in 04489_recursive_cte_join_index.sql currently locks in the same mismatch. Please make this helper answer the full outer-join-tree question from allowParallelReplicasForJoinTree(), not just the VIEW / remote-right subsets.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@rschu1ze — tagging you on this one as JOIN-related, as requested. Review request sent too.

@abashkeev abashkeev added the comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. label Sep 3, 2026
@rschu1ze

rschu1ze commented Sep 3, 2026

Copy link
Copy Markdown
Member

I think there can be a better approach: #75026 (comment)

@alexey-milovidov

Copy link
Copy Markdown
Member Author

See #97254 (comment)

@groeneai

groeneai commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Closing out the Stress test (arm_asan_ubsan) "Cannot start clickhouse-server" item from your 2026-05-13 directive, which my 2026-05-14 reply left open. Both halves of the timeline you wrote are now fixed in tests/docker_scripts/stress_tests.lib.

The clickhouse start re-invocation cascade you saw as Address already in use was fixed in #106806: a restart happens only when the previous daemon has actually exited, and the wait-for-free-ports step covers all 13 listen ports instead of 3.

The window elapsing while the last start was still coming up was fixed in #117094 (merged 2026-09-03). The give-up test counted poll iterations rather than elapsed time, so the budget was a fixed 8 polls with sleep 10 between them, about 71 s, no matter how long the binary needed. Each daemon instance now gets its own readiness deadline, re-anchored on every start, while the attempt count keeps bounding a server that really did exit.

Cannot start clickhouse-server is a multi-cause bucket, so runs still printing it can have unrelated causes with their own fixes (Code 246 part intersection, #111055; an Alias-chain table fatal to ATTACH, #116153).

CIDB for this check: the last true-master hit for Stress test (arm_asan_ubsan*) was 2026-07-21, and 0 of the 23 rows in the last 30 days are master, against 62 rows and 2 master in the 30 days before. #117094 is too recent to appear in those numbers.

zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The 02995_new_settings_history test compares current settings against the
previous release's defaults and expects every newly added setting to appear
under a version > 26.4 in `SettingsChangesHistory.cpp`. The current
development version is 26.5, so the entry for `recursive_cte_max_in_filter_cardinality`
must live in the 26.5 section, not 26.4.

Failing CI: ClickHouse#97254

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The earlier `cffd1a9` simplification overrode parallel replicas only on the
interpreter context passed to `InterpreterSelectQueryAnalyzer`. The planner
reads the setting from each `QueryNode`/`UnionNode`'s own `mutable_context`
(see `Planner::buildPlannerContext`), so inner nodes still saw parallel
replicas enabled and `Stateless tests (amd_llvm_coverage, ParallelReplicas,
s3 storage, parallel)` failed on `03924_recursive_cte_join_index` with
`TOO_MANY_ROWS` from `ReadPoolParallelReplicas`.

Rewrite each `QueryNode`/`UnionNode`'s `mutable_context` in the recursive
query once at construction time. Original sharing is preserved: nodes that
shared a context originally share the same copy afterwards. Drops the
no-longer-needed per-step context override in `buildStepExecutor`.

CI report: ClickHouse#97254
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The previous commit updated the entry's description to reference `26.6`
but left the entry itself inside the `26.5` block, so the
`02995_new_settings_history` Fast test still reported the new
default-value change as unregistered.

Move the entry into the `26.6` block to match its description and
satisfy the version-bound check used by `02995_new_settings_history`.

PR=ClickHouse#97254
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recursive CTE does not use index on JOIN key, causing large scans for each recursion step

6 participants