嵌套循环并行查询
功能描述
嵌套循环并行查询是利用多核CPU的并行处理,将一个表连接语句由多个并行worker线程执行。
示例
创建两张表:
create table t1(a int,b int,c int,d bigint);
create table t2(a int,b int);
插入数据并分析表:
insert into t1 values
(generate_series(1,100),generate_series(1,10),generate_series(1,2),generate_series(1,50));
insert into t2 values(generate_series(1,100),generate_series(1,30));
analyze t1;
analyze t2;
设置算子并行度和表连接代价开关:
set query_drop=2;
set enable_nestloop=on;
set enable_mergejoin=off;
set enable_hashjoin=off;
打印嵌套循环并行查询计划
explain (costs off) select t1.a,t2.b from t1,t2 where t1.a=t2.a order by 1,2;