clickhouse 中select in操作

https://clickhouse.yandex/docs/en/operations/settings/settings/

distributed_product_mode

Changes the behavior of distributed subqueries.

ClickHouse applies this setting when the query contains the product of distributed tables, i.e. when the query for a distributed table contains a non-GLOBAL subquery for the distributed table.

Restrictions:

  • Only applied for IN and JOIN subqueries.
  • Only if the FROM section uses a distributed table containing more than one shard.
  • If the subquery concerns a distributed table containing more than one shard,
  • Not used for a table-valued remote function.

The possible values are:

  • deny — Default value. Prohibits using these types of subqueries (returns the "Double-distributed in/JOIN subqueries is denied" exception).
  • local — Replaces the database and table in the subquery with local ones for the destination server (shard), leaving the normal IN / JOIN.
  • global — Replaces the IN / JOIN query with GLOBAL IN / GLOBAL JOIN.
  • allow — Allows the use of these types of subqueries.
  • https://blog.csdn.net/ma15732625261/article/details/86607199
  • 分布式子查询

    带有子查询的in

    1、普通in,查询发送到远程服务器,且每个服务器中运行in或join子句的子查询

    2、global in、global join时,先为global in、global join运行所有子查询,将结果收到临时表且将表发给每个服务器,使用临时表运行查询

    非分布式查询,使用普通的in、join

    假设集群中每个服务器都存在一个正常表local_table,与分布式表distributed_table

       对distributed_table查询,查询被送到服务器且使用local_table运行查询

原文地址:https://www.cnblogs.com/miaoer/p/10592841.html