All Products
Search
Document Center

PolarDB:Parallel query usage examples

Last Updated:Mar 28, 2026

This page shows how parallel queries perform across 11 SQL constructs, measured on TPC Benchmark™H (TPC-H) workloads. For each construct, you can compare execution times before and after enabling parallel query on the same cluster.

Note

This test is based on the TPC-H benchmark but does not meet all TPC-H requirements. Results may differ from published TPC-H benchmark figures.

Test environment

ParameterValue
Data volume100 GB (scale factor 100)
ClusterPolarDB for MySQL 8.0
Node specification88 CPU cores, 710 GB memory
Test targetPrimary node

Performance summary

The table below summarizes execution time before and after enabling parallel query across all tested SQL constructs.

SQL constructParallel query offParallel query onTime reduction
GROUP BY and ORDER BY1,563.32s49.65s96.82%
Aggregate functions (SUM, AVG, COUNT)1,563.32s49.65s96.82%
JOIN21.73s1.37s93.70%
BETWEEN and IN21.73s1.37s93.70%
LIMIT339.22s29.31s91.36%
INTERVAL220.87s7.75s96.49%
CASE WHEN220.87s7.75s96.49%
LIKE427.46s33.72s92.11%
Subqueries9.27s1.12s88.00%
GROUP BY WITH ROLLUP318.73s22.30s93.00%
INSERT ... SELECT and REPLACE ... SELECT182.82s23.25s87.28%

GROUP BY and ORDER BY

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;
Execution time
Parallel query off1,563.32s
Parallel query on49.65s (3.18% of original)
  • Parallel query off: 不打开

  • Parallel query on: 打开并行查询

Aggregate functions (SUM, AVG, and COUNT)

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;
Execution time
Parallel query off1,563.32s
Parallel query on49.65s (3.18% of original)
  • Parallel query off: off

  • Parallel query on: on

JOIN

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' );
Execution time
Parallel query off21.73s
Parallel query on1.37s (6.30% of original)
  • Parallel query off: off

  • Parallel query on: on

BETWEEN and IN

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' );
Execution time
Parallel query off21.73s
Parallel query on1.37s (6.30% of original)
  • Parallel query off: off

  • Parallel query on: on

LIMIT

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;
Execution time
Parallel query off339.22s
Parallel query on29.31s (8.64% of original)
  • Parallel query off: off

  • Parallel query on: on

INTERVAL

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;
Execution time
Parallel query off220.87s
Parallel query on7.75s (3.51% of original)
  • Parallel query off: off

  • Parallel query on: on

CASE WHEN

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;
Execution time
Parallel query off220.87s
Parallel query on7.75s (3.51% of original)
  • Parallel query off: off

  • Parallel query on: on

LIKE

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;
Execution time
Parallel query off427.46s
Parallel query on33.72s (7.89% of original)
  • Parallel query off: 1

  • Parallel query on: 2

Subqueries

select
    s_acctbal,
    s_name,
    n_name,
    p_partkey,
    p_mfgr,
    s_address,
    s_phone,
    s_comment
from
    part,
    supplier,
    partsupp,
    nation,
    region
where
    p_partkey = ps_partkey
    and s_suppkey = ps_suppkey
    and p_size = 35
    and p_type like '%STEEL'
    and s_nationkey = n_nationkey
    and n_regionkey = r_regionkey
    and r_name = 'AMERICA'
    and ps_supplycost = (
        select
            min(ps_supplycost)
        from
            partsupp,
            supplier,
            nation,
            region
        where
            p_partkey = ps_partkey
            and s_suppkey = ps_suppkey
            and s_nationkey = n_nationkey
            and n_regionkey = r_regionkey
            and r_name = 'AMERICA'
    )
order by
    s_acctbal desc,
    n_name,
    s_name,
    p_partkey;
limit 1;
Execution time
Parallel query off9.27s
Parallel query on1.12s (12% of original)
  • Parallel query off: SUBQUERY支持-前

  • Parallel query on: SUBQUERY支持-后

GROUP BY WITH ROLLUP

For background on GROUP BY WITH ROLLUP, see MySQL ROLLUP.

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_sub('1998-12-01', interval ':1' day)
group by
    l_returnflag,
    l_linestatus
with rollup
order by
    l_returnflag,
    l_linestatus;
Execution time
Parallel query off318.73s
Parallel query on22.30s (7.00% of original)
  • Parallel query off: GROUP BY WITH ROLLUP-前

  • Parallel query on: GROUP BY WITH ROLLUP-后

INSERT ... SELECT and REPLACE ... SELECT

insert into line_item_ap
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;
Execution time
Parallel query off182.82s
Parallel query on23.25s (12.72% of original)
  • Parallel query off: INSERT ... SELECT/REPLACE ... SELECT-前

  • Parallel query on: INSERT ... SELECT/REPLACE ... SELECT-后