pingcap / go-tpc

A toolbox to benchmark TPC workloads in Go
Apache License 2.0
178 stars 94 forks source link

tpcc: the sql of checkCondition10 is inefficient #176

Open starxchina opened 4 months ago

starxchina commented 4 months ago

the follow sql is not efficient when I check the data.

SELECT Count(*)
FROM   (SELECT c.c_id,
               c.c_d_id,
               c.c_w_id,
               c.c_balance                  c1,
               (SELECT Sum(ol_amount)
                FROM   orders,
                       order_line
                WHERE  ol_w_id = o_w_id
                       AND ol_d_id = o_d_id
                       AND ol_o_id = o_id
                       AND ol_delivery_d IS NOT NULL
                       AND o_w_id =?
                       AND o_d_id = c.c_d_id
                       AND o_c_id = c.c_id) sm,
               (SELECT Sum(h_amount)
                FROM   history
                WHERE  h_c_w_id =?
                       AND h_c_d_id = c.c_d_id
                       AND h_c_id = c.c_id) smh
        FROM   customer c
        WHERE  c.c_w_id = ?) t
WHERE  c1 <> sm - smh