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

ContextPtr query_context,
    const ASTPtr & query ,
    bool filter_by_database_virtual_column ,
    bool filter_by_table_virtual_column ) const
{
    assert(!filter_by_database_virtual_column || !filter_by_table_virtual_column || query);
    const Settings & settings = query_context->getSettingsRef();
    StorageListWithLocks selected_tables;
    DatabaseTablesIterators database_table_iterators = getDatabaseIterators(getContext());
    MutableColumnPtr database_name_virtual_column;
    MutableColumnPtr table_name_virtual_column;
    if (filter_by_database_virtual_column)
    {
        database_name_virtual_column = ColumnString::create();
    }
    if (filter_by_table_virtual_column)
    {
        table_name_virtual_column = ColumnString::create();
    }