このページでは、TPC-H クエリを例として使用し、並列クエリの使用方法を説明します。 すべての例で、使用されるデータ量は TPC-H ベンチマークで定義されている SF = 100 GB です。 テストされた POLARDB ノードは、88 コアの CPU と 710 GB のメモリを備えたプライマリノードです。

GROUP BY および ORDER BY のサポート

並列クエリを無効にすると、クエリの実行に 1,563.32 秒かかります。 並列クエリを有効にすると、クエリの実行に 49.65 秒しかかかりません。これは、元のクエリ時間より 31.48 倍短い時間です。

以下に、元の SQL 文の例を示します。
SELECT   l_returnflag, 
         l_linestatus, 
         Sum(l_quantity)                                       AS sum_qty, 
         Sum(l_extendedprice)                                  AS sum_base_price, 
         Sum(l_extendedprice * (1 - l_discount))               AS sum_disc_price, 
         Sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, 
         Avg(l_quantity)                                       AS avg_qty, 
         Avg(l_extendedprice)                                  AS avg_price, 
         Avg(l_discount)                                       AS avg_disc, 
         Count(*)                                              AS count_order 
FROM     lineitem
WHERE    l_shipdate <= date '1998-12-01' - INTERVAL '93' day 
GROUP BY l_returnflag, 
         l_linestatus 
ORDER BY l_returnflag, 
         l_linestatus ;
並列クエリを無効にすると、クエリの実行に 1,563.32 秒かかります。不打开
並列クエリを有効にすると、クエリの実行に 49.65 秒しかかかりません。これは、元のクエリ時間より 31.48 倍短い時間です。打开并行查询

AGGREGATE 関数 (SUM/AVG/COUNT) のサポート

並列クエリを無効にすると、クエリの実行に 1,563.32 秒かかります。 並列クエリを有効にすると、クエリの実行に 49.65 秒しかかかりません。これは、元のクエリ時間より 31.48 倍短い時間です。

以下に、元の SQL 文の例を示します。
SELECT   l_returnflag, 
         l_linestatus, 
         Sum(l_quantity)                                       AS sum_qty, 
         Sum(l_extendedprice)                                  AS sum_base_price, 
         Sum(l_extendedprice * (1 - l_discount))               AS sum_disc_price, 
         Sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, 
         Avg(l_quantity)                                       AS avg_qty, 
         Avg(l_extendedprice)                                  AS avg_price, 
         Avg(l_discount)                                       AS avg_disc, 
         Count(*)                                              AS count_order 
FROM     lineitem
WHERE    l_shipdate <= date '1998-12-01' - INTERVAL '93' day 
GROUP BY l_returnflag, 
         l_linestatus 
ORDER BY l_returnflag, 
         l_linestatus ;
並列クエリを無効にすると、クエリの実行に 1,563.32 秒かかります。 off
並列クエリを有効にすると、クエリの実行に 49.65 秒しかかかりません。これは、元のクエリ時間より 31.48 倍短い時間です。on

JOIN のサポート

並列クエリを無効にすると、クエリの実行に 21.73 秒かかります。 並列クエリを有効にすると、クエリの実行に 1.37 秒しかかかりません。これは、元のクエリ時間より 15.86 倍短い時間です。

以下に、元の SQL 文の例を示します。
select sum(l_extendedprice* (1 - l_discount)) as revenue 
from   lineitem,   part 
where ( p_partkey = l_partkey and p_brand = 'Brand#12'
        and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') 
        and l_quantity >= 6 and l_quantity <= 6 + 10 
        and p_size between 1 and 5 
        and l_shipmode in ('AIR', 'AIR REG') 
        and l_shipinstruct = 'DELIVER IN PERSON' ) 
    or ( p_partkey = l_partkey and p_brand = 'Brand#13'
        and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') 
        and l_quantity >= 10 and l_quantity <= 10 + 10 
        and p_size between 1 and 10 
        and l_shipmode in ('AIR', 'AIR REG') 
        and l_shipinstruct = 'DELIVER IN PERSON' ) 
    or ( p_partkey = l_partkey and p_brand = 'Brand#24'
        and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') 
        and l_quantity >= 21 and l_quantity <= 21 + 10 
        and p_size between 1 and 15 
        and l_shipmode in ('AIR', 'AIR REG') 
        and l_shipinstruct = 'DELIVER IN PERSON' ); 
並列クエリを無効にすると、クエリの実行に 21.73 秒かかります。off
並列クエリを有効にすると、クエリの実行に 1.37 秒しかかかりません。これは、元のクエリ時間より 15.86 倍短い時間です。on

BETWEEN 関数と IN 関数のサポート

並列クエリを無効にすると、クエリの実行に 21.73 秒かかります。 並列クエリを有効にすると、クエリの実行に 1.37 秒しかかかりません。これは、元のクエリ時間より 15.86 倍短い時間です。

以下に、元の SQL 文の例を示します。
select sum(l_extendedprice* (1 - l_discount)) as revenue 
from   lineitem,   part 
where ( p_partkey = l_partkey and p_brand = 'Brand#12'
        and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') 
        and l_quantity >= 6 and l_quantity <= 6 + 10 
        and p_size between 1 and 5 
        and l_shipmode in ('AIR', 'AIR REG') 
        and l_shipinstruct = 'DELIVER IN PERSON' ) 
    or ( p_partkey = l_partkey and p_brand = 'Brand#13'
        and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') 
        and l_quantity >= 10 and l_quantity <= 10 + 10 
        and p_size between 1 and 10 
        and l_shipmode in ('AIR', 'AIR REG') 
        and l_shipinstruct = 'DELIVER IN PERSON' ) 
    or ( p_partkey = l_partkey and p_brand = 'Brand#24'
        and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') 
        and l_quantity >= 21 and l_quantity <= 21 + 10 
        and p_size between 1 and 15 
        and l_shipmode in ('AIR', 'AIR REG') 
        and l_shipinstruct = 'DELIVER IN PERSON' ); 
並列クエリを無効にすると、クエリの実行に 21.73 秒かかります。off
並列クエリを有効にすると、クエリの実行に 1.37 秒しかかかりません。これは、元のクエリ時間より 15.86 倍短い時間です。on

LIMIT のサポート

並列クエリを無効にすると、クエリの実行に 339.22 秒かかります。 並列クエリを有効にすると、クエリの実行に 29.31 秒しか必要ありません。これは、元のクエリ時間より 11.57 倍短い時間です。

以下に、元の SQL 文の例を示します。
select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 
    else 0 
end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 
else 0 
end) as low_line_count 
from   orders,   lineitem 
where o_orderkey = l_orderkey 
and l_shipmode in ('MAIL', 'TRUCK') 
and l_commitdate < l_receiptdate 
and l_shipdate < l_commitdate 
and l_receiptdate >= date '1996-01-01' 
and l_receiptdate < date '1996-01-01' + interval '1' year 
group by l_shipmode 
order by l_shipmode limit 10; 
並列クエリを無効にすると、クエリの実行に 339.22 秒かかります。off
並列クエリを有効にすると、クエリの実行に 29.31 秒しか必要ありません。これは、元のクエリ時間より 11.57 倍短い時間です。on

INTERVAL 関数のサポート

並列クエリを無効にすると、クエリの実行に 220.87 秒かかります。 並列クエリを有効にした後は、クエリの実行に 7.75 秒しか必要ありません。これは、元のクエリ時間より 28.5 倍短い時間です。

以下に、元の SQL 文の例を示します。
select 
    100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) 
    else 0 
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue 
from   lineitem,   part 
where l_partkey = p_partkey
and l_shipdate >= date '1996-01-01' 
and l_shipdate < date '1996-01-01' + interval '1' month limit 10; 
並列クエリを無効にすると、クエリの実行に 220.87 秒かかります。off
並列クエリを有効にした後は、クエリの実行に 7.75 秒しか必要ありません。これは、元のクエリ時間より 28.5 倍短い時間です。on

CASE WHEN のサポート

並列クエリを無効にすると、クエリの実行に 220.87 秒かかります。 並列クエリを有効にした後は、クエリの実行に 7.75 秒しか必要ありません。これは、元のクエリ時間より 28.5 倍短い時間です。

以下に、元の SQL 文の例を示します。
select 
    100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) 
    else 0 
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue 
from   lineitem,   part 
where l_partkey = p_partkey
and l_shipdate >= date '1996-01-01' 
and l_shipdate < date '1996-01-01' + interval '1' month limit 10; 
並列クエリを無効にすると、クエリの実行に 220.87 秒かかります。off
並列クエリを有効にした後は、クエリの実行に 7.75 秒しか必要ありません。これは、元のクエリ時間より28.5倍短い時間です。on

LIKE のサポート

並列クエリを無効にすると、クエリの実行に427.46秒かかります。 並列クエリを有効にすると、クエリの実行に 33.72 秒しかかかりません。これは、元のクエリ時間より 12.68 倍短い時間です。

以下に、元の SQL 文の例を示します。
select s_name, s_address from
 supplier,  nation where
s_suppkey in 
    ( select ps_suppkey from  partsupp where
             ps_partkey in ( select p_partkey from  part where p_name like 'dark%')
            and ps_availqty>(select 0.0005 * sum(l_quantity) as col1
     from   lineitem,   partsupp
     where l_partkey = ps_partkey and l_suppkey = ps_suppkey
     and l_shipdate >= date '1993-01-01' and l_shipdate < date '1993-01-01' + interval '1' year)
    )
and s_nationkey = n_nationkey and n_name = 'JORDAN'
order by s_name limit 10; 
並列クエリを無効にすると、クエリの実行に 427.46 秒かかります。
並列クエリを有効にすると、クエリの実行に 33.72 秒しかかかりません。これは、元のクエリ時間より 12.68 倍短い時間です。