Skip to content

tpcc: the sql of checkCondition10 is inefficient #176

@starxchina

Description

@starxchina

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions