We use Merge Table Engine to merge a ReplicatedMergeTree Engine table and a normal view without Distributed Table Engine based on another ReplicatedMergeTree Engine table.

And we found that the Merge Table Engine does not use the indexes of view.

But if we use Distributed Table Engine to make these tables and views distributed, the Merge Table Engine will use their indexes.

So what is the difference between these two modes?


ClickHouse version: 21.9.2.17

if (!input_sorting_info)
                break;
        }
        query_info.input_order_info = input_sorting_info;
    }
    auto sample_block = merge_storage_snapshot->getMetadataForQuery()->getSampleBlock();
    std::vector<std::unique_ptr<QueryPipelineBuilder>> pipelines;
    QueryPlanResourceHolder resources;
    for (const auto & table : selected_tables)
    {
        size_t current_need_streams = tables_count >= num_streams ? 1 : (num_streams / tables_count);
        size_t current_streams = std::min(current_need_streams, remaining_streams);
        remaining_streams -= current_streams;
        current_streams = std::max(static_cast<size_t>(1), current_streams);
        const auto & storage = std::get<1>(table);
        
        if (query_info.query->as<ASTSelectQuery>()->sampleSize() && !storage->supportsSampling())
            throw Exception("Illegal SAMPLE: table doesn't support sampling", ErrorCodes::SAMPLING_NOT_SUPPORTED);
        Aliases aliases;
        auto storage_metadata_snapshot = storage->getInMemoryMetadataPtr();
        auto storage_columns = storage_metadata_snapshot->getColumns();
        auto nested_storage_snaphsot = storage->getStorageSnapshot(storage_metadata_snapshot, context);
        auto modified_query_info = getModifiedQueryInfo(query_info, context, storage->getStorageID(), storage->as<StorageMerge>());
        auto syntax_result = TreeRewriter(context).analyzeSelect(
            modified_query_info.query, TreeRewriterResult({}, storage, nested_storage_snaphsot));
        Names column_names_as_aliases;
        bool with_aliases = common_processed_stage == QueryProcessingStage::FetchColumns && !storage_columns.getAliases().empty();
        if (with_aliases)
        {
            ASTPtr required_columns_expr_list = std::make_shared<ASTExpressionList>();