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

{
    try
    {
        checkStackSize();
    }
    catch (Exception & e)
    {
        e.addMessage("while getting table iterator of Merge table. Maybe caused by two Merge tables that will endlessly try to read each other's data");
        throw;
    }
    DatabaseTablesIterators database_table_iterators;
    
    if (!database_is_regexp)
        database_table_iterators.emplace_back(getDatabaseIterator(source_database_name_or_regexp, local_context));
    
    else
    {
        auto databases = DatabaseCatalog::instance().getDatabases();
        for (const auto & db : databases)
        {
            if (source_database_regexp->match(db.first))
                database_table_iterators.emplace_back(getDatabaseIterator(db.first, local_context));
        }
    }
    return database_table_iterators;
}
void StorageMerge::checkAlterIsPossible(const AlterCommands & commands, ContextPtr local_context) const