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

Block common_header_,
    StorageListWithLocks selected_tables_,
    Names column_names_,
    bool has_database_virtual_column_,
    bool has_table_virtual_column_,
    size_t max_block_size,
    size_t num_streams,
    StoragePtr storage,
    StorageSnapshotPtr storage_snapshot,
    const SelectQueryInfo & query_info_,
    ContextMutablePtr context_,
    QueryProcessingStage::Enum processed_stage)
    : ISourceStep(DataStream{.header = common_header_})
    , required_max_block_size(max_block_size)
    , requested_num_streams(num_streams)
    , common_header(std::move(common_header_))
    , selected_tables(std::move(selected_tables_))
    , column_names(std::move(column_names_))
    , has_database_virtual_column(has_database_virtual_column_)
    , has_table_virtual_column(has_table_virtual_column_)
    , storage_merge(std::move(storage))
    , merge_storage_snapshot(std::move(storage_snapshot))
    , query_info(query_info_)
    , context(std::move(context_))
    , common_processed_stage(processed_stage)
{
}
void ReadFromMerge::initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)