exec-ddl
CREATE TABLE warehouse
(
    w_id        integer   not null primary key,
    w_name      varchar(10),
    w_street_1  varchar(20),
    w_street_2  varchar(20),
    w_city      varchar(20),
    w_state     char(2),
    w_zip       char(9),
    w_tax       decimal(4,4),
    w_ytd       decimal(12,2)
)
----
TABLE warehouse
 ├── w_id int not null
 ├── w_name string
 ├── w_street_1 string
 ├── w_street_2 string
 ├── w_city string
 ├── w_state string
 ├── w_zip string
 ├── w_tax decimal
 ├── w_ytd decimal
 └── INDEX primary
      └── w_id int not null

exec-ddl
CREATE TABLE district
(
    d_id         integer       not null,
    d_w_id       integer       not null,
    d_name       varchar(10),
    d_street_1   varchar(20),
    d_street_2   varchar(20),
    d_city       varchar(20),
    d_state      char(2),
    d_zip        char(9),
    d_tax        decimal(4,4),
    d_ytd        decimal(12,2),
    d_next_o_id  integer,
    primary key (d_w_id, d_id),
    foreign key (d_w_id) references warehouse (w_id)
) interleave in parent warehouse (d_w_id)
----
TABLE district
 ├── d_id int not null
 ├── d_w_id int not null
 ├── d_name string
 ├── d_street_1 string
 ├── d_street_2 string
 ├── d_city string
 ├── d_state string
 ├── d_zip string
 ├── d_tax decimal
 ├── d_ytd decimal
 ├── d_next_o_id int
 └── INDEX primary
      ├── d_w_id int not null
      └── d_id int not null

exec-ddl
CREATE TABLE customer
(
    c_id           integer        not null,
    c_d_id         integer        not null,
    c_w_id         integer        not null,
    c_first        varchar(16),
    c_middle       char(2),
    c_last         varchar(16),
    c_street_1     varchar(20),
    c_street_2     varchar(20),
    c_city         varchar(20),
    c_state        char(2),
    c_zip          char(9),
    c_phone        char(16),
    c_since        timestamp,
    c_credit       char(2),
    c_credit_lim   decimal(12,2),
    c_discount     decimal(4,4),
    c_balance      decimal(12,2),
    c_ytd_payment  decimal(12,2),
    c_payment_cnt  integer,
    c_delivery_cnt integer,
    c_data         varchar(500),
    primary key (c_w_id, c_d_id, c_id),
    index customer_idx (c_w_id, c_d_id, c_last, c_first),
    foreign key (c_w_id, c_d_id) references district (d_w_id, d_id)
) interleave in parent district (c_w_id, c_d_id)
----
TABLE customer
 ├── c_id int not null
 ├── c_d_id int not null
 ├── c_w_id int not null
 ├── c_first string
 ├── c_middle string
 ├── c_last string
 ├── c_street_1 string
 ├── c_street_2 string
 ├── c_city string
 ├── c_state string
 ├── c_zip string
 ├── c_phone string
 ├── c_since timestamp
 ├── c_credit string
 ├── c_credit_lim decimal
 ├── c_discount decimal
 ├── c_balance decimal
 ├── c_ytd_payment decimal
 ├── c_payment_cnt int
 ├── c_delivery_cnt int
 ├── c_data string
 ├── INDEX primary
 │    ├── c_w_id int not null
 │    ├── c_d_id int not null
 │    └── c_id int not null
 └── INDEX customer_idx
      ├── c_w_id int not null
      ├── c_d_id int not null
      ├── c_last string
      ├── c_first string
      └── c_id int not null

exec-ddl
CREATE TABLE history
(
    rowid    uuid PRIMARY KEY DEFAULT gen_random_uuid(),
    h_c_id   integer,
    h_c_d_id integer,
    h_c_w_id integer,
    h_d_id   integer,
    h_w_id   integer,
    h_date   timestamp,
    h_amount decimal(6,2),
    h_data   varchar(24),
    index (h_w_id, h_d_id),
    index (h_c_w_id, h_c_d_id, h_c_id),
    foreign key (h_c_w_id, h_c_d_id, h_c_id) references customer (c_w_id, c_d_id, c_id),
    foreign key (h_w_id, h_d_id) references district (d_w_id, d_id)
)
----
TABLE history
 ├── rowid uuid not null
 ├── h_c_id int
 ├── h_c_d_id int
 ├── h_c_w_id int
 ├── h_d_id int
 ├── h_w_id int
 ├── h_date timestamp
 ├── h_amount decimal
 ├── h_data string
 ├── INDEX primary
 │    └── rowid uuid not null
 ├── INDEX secondary
 │    ├── h_w_id int
 │    ├── h_d_id int
 │    └── rowid uuid not null
 └── INDEX secondary
      ├── h_c_w_id int
      ├── h_c_d_id int
      ├── h_c_id int
      └── rowid uuid not null

exec-ddl
CREATE TABLE "order"
(
    o_id         integer      not null,
    o_d_id       integer      not null,
    o_w_id       integer      not null,
    o_c_id       integer,
    o_entry_d    timestamp,
    o_carrier_id integer,
    o_ol_cnt     integer,
    o_all_local  integer,
    primary key (o_w_id, o_d_id, o_id DESC),
    unique index order_idx (o_w_id, o_d_id, o_carrier_id, o_id),
    index (o_w_id, o_d_id, o_c_id),
    foreign key (o_w_id, o_d_id, o_c_id) references customer (c_w_id, c_d_id, c_id)
) interleave in parent district (o_w_id, o_d_id)
----
TABLE order
 ├── o_id int not null
 ├── o_d_id int not null
 ├── o_w_id int not null
 ├── o_c_id int
 ├── o_entry_d timestamp
 ├── o_carrier_id int
 ├── o_ol_cnt int
 ├── o_all_local int
 ├── INDEX primary
 │    ├── o_w_id int not null
 │    ├── o_d_id int not null
 │    └── o_id int not null desc
 ├── INDEX order_idx
 │    ├── o_w_id int not null
 │    ├── o_d_id int not null
 │    ├── o_carrier_id int
 │    └── o_id int not null
 └── INDEX secondary
      ├── o_w_id int not null
      ├── o_d_id int not null
      ├── o_c_id int
      └── o_id int not null

exec-ddl
CREATE TABLE new_order
(
    no_o_id  integer   not null,
    no_d_id  integer   not null,
    no_w_id  integer   not null,
    primary key (no_w_id, no_d_id, no_o_id DESC)
) interleave in parent "order" (no_w_id, no_d_id, no_o_id)
----
TABLE new_order
 ├── no_o_id int not null
 ├── no_d_id int not null
 ├── no_w_id int not null
 └── INDEX primary
      ├── no_w_id int not null
      ├── no_d_id int not null
      └── no_o_id int not null desc

exec-ddl
CREATE TABLE item
(
    i_id     integer      not null,
    i_im_id  integer,
    i_name   varchar(24),
    i_price  decimal(5,2),
    i_data   varchar(50),
    primary key (i_id)
)
----
TABLE item
 ├── i_id int not null
 ├── i_im_id int
 ├── i_name string
 ├── i_price decimal
 ├── i_data string
 └── INDEX primary
      └── i_id int not null

exec-ddl
CREATE TABLE stock
(
    s_i_id       integer       not null,
    s_w_id       integer       not null,
    s_quantity   integer,
    s_dist_01    char(24),
    s_dist_02    char(24),
    s_dist_03    char(24),
    s_dist_04    char(24),
    s_dist_05    char(24),
    s_dist_06    char(24),
    s_dist_07    char(24),
    s_dist_08    char(24),
    s_dist_09    char(24),
    s_dist_10    char(24),
    s_ytd        integer,
    s_order_cnt  integer,
    s_remote_cnt integer,
    s_data       varchar(50),
    primary key (s_w_id, s_i_id),
    index (s_i_id),
    foreign key (s_w_id) references warehouse (w_id),
    foreign key (s_i_id) references item (i_id)
) interleave in parent warehouse (s_w_id)
----
TABLE stock
 ├── s_i_id int not null
 ├── s_w_id int not null
 ├── s_quantity int
 ├── s_dist_01 string
 ├── s_dist_02 string
 ├── s_dist_03 string
 ├── s_dist_04 string
 ├── s_dist_05 string
 ├── s_dist_06 string
 ├── s_dist_07 string
 ├── s_dist_08 string
 ├── s_dist_09 string
 ├── s_dist_10 string
 ├── s_ytd int
 ├── s_order_cnt int
 ├── s_remote_cnt int
 ├── s_data string
 ├── INDEX primary
 │    ├── s_w_id int not null
 │    └── s_i_id int not null
 └── INDEX secondary
      ├── s_i_id int not null
      └── s_w_id int not null

exec-ddl
CREATE TABLE order_line
(
    ol_o_id         integer   not null,
    ol_d_id         integer   not null,
    ol_w_id         integer   not null,
    ol_number       integer   not null,
    ol_i_id         integer   not null,
    ol_supply_w_id  integer,
    ol_delivery_d   timestamp,
    ol_quantity     integer,
    ol_amount       decimal(6,2),
    ol_dist_info    char(24),
    primary key (ol_w_id, ol_d_id, ol_o_id DESC, ol_number),
    index order_line_fk (ol_supply_w_id, ol_d_id),
    foreign key (ol_w_id, ol_d_id, ol_o_id) references "order" (o_w_id, o_d_id, o_id),
    foreign key (ol_supply_w_id, ol_d_id) references stock (s_w_id, s_i_id)
) interleave in parent "order" (ol_w_id, ol_d_id, ol_o_id)
----
TABLE order_line
 ├── ol_o_id int not null
 ├── ol_d_id int not null
 ├── ol_w_id int not null
 ├── ol_number int not null
 ├── ol_i_id int not null
 ├── ol_supply_w_id int
 ├── ol_delivery_d timestamp
 ├── ol_quantity int
 ├── ol_amount decimal
 ├── ol_dist_info string
 ├── INDEX primary
 │    ├── ol_w_id int not null
 │    ├── ol_d_id int not null
 │    ├── ol_o_id int not null desc
 │    └── ol_number int not null
 └── INDEX order_line_fk
      ├── ol_supply_w_id int
      ├── ol_d_id int not null
      ├── ol_w_id int not null
      ├── ol_o_id int not null
      └── ol_number int not null

# --------------------------------------------------
# 2.4 The New Order Transaction
#
# The New-Order business transaction consists of entering a complete order
# through a single database transaction. It represents a mid-weight, read-write
# transaction with a high frequency of execution and stringent response time
# requirements to satisfy on-line users. This transaction is the backbone of
# the workload. It is designed to place a variable load on the system to
# reflect on-line database activity as typically found in production
# environments.
# --------------------------------------------------
opt format=hide-qual
SELECT w_tax FROM warehouse WHERE w_id = 10
----
project
 ├── columns: w_tax:8(decimal)
 ├── cardinality: [0 - 1]
 ├── stats: [rows=1]
 ├── cost: 1.12
 ├── key: ()
 ├── fd: ()-->(8)
 ├── prune: (8)
 └── scan warehouse
      ├── columns: w_id:1(int!null) w_tax:8(decimal)
      ├── constraint: /1: [/10 - /10]
      ├── cardinality: [0 - 1]
      ├── stats: [rows=1, distinct(1)=1]
      ├── cost: 1.11
      ├── key: ()
      ├── fd: ()-->(1,8)
      ├── prune: (1,8)
      └── interesting orderings: (+1)

opt format=hide-qual
SELECT c_discount, c_last, c_credit
FROM customer
WHERE c_w_id = 10 AND c_d_id = 100 AND c_id = 50
----
project
 ├── columns: c_discount:16(decimal) c_last:6(string) c_credit:14(string)
 ├── cardinality: [0 - 1]
 ├── stats: [rows=0.001]
 ├── cost: 0.00128
 ├── key: ()
 ├── fd: ()-->(6,14,16)
 ├── prune: (6,14,16)
 └── scan customer
      ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_last:6(string) c_credit:14(string) c_discount:16(decimal)
      ├── constraint: /3/2/1: [/10/100/50 - /10/100/50]
      ├── cardinality: [0 - 1]
      ├── stats: [rows=0.001, distinct(1)=0.001, distinct(2)=0.001, distinct(3)=0.001]
      ├── cost: 0.00127
      ├── key: ()
      ├── fd: ()-->(1-3,6,14,16)
      ├── prune: (1-3,6,14,16)
      └── interesting orderings: (+3,+2,+1) (+3,+2,+6)

opt format=hide-qual
SELECT i_price, i_name, i_data
FROM item
WHERE i_id IN (125, 150, 175, 200, 25, 50, 75, 100, 225, 250, 275, 300)
ORDER BY i_id
----
scan item
 ├── columns: i_price:4(decimal) i_name:3(string) i_data:5(string)
 ├── constraint: /1: [/25 - /25] [/50 - /50] [/75 - /75] [/100 - /100] [/125 - /125] [/150 - /150] [/175 - /175] [/200 - /200] [/225 - /225] [/250 - /250] [/275 - /275] [/300 - /300]
 ├── stats: [rows=12, distinct(1)=12]
 ├── cost: 13.08
 ├── key: (1)
 ├── fd: (1)-->(3-5)
 ├── ordering: +1
 ├── prune: (3-5)
 └── interesting orderings: (+1)

opt format=hide-qual
SELECT s_quantity, s_ytd, s_order_cnt, s_remote_cnt, s_data, s_dist_05
FROM stock
WHERE (s_i_id, s_w_id) IN ((1000, 4), (900, 4), (1100, 4), (1500, 4), (1400, 4))
ORDER BY s_i_id
----
project
 ├── columns: s_quantity:3(int) s_ytd:14(int) s_order_cnt:15(int) s_remote_cnt:16(int) s_data:17(string) s_dist_05:8(string)
 ├── stats: [rows=0.5]
 ├── cost: 0.63
 ├── key: (1)
 ├── fd: (1)-->(3,8,14-17)
 ├── ordering: +1
 ├── prune: (1,3,8,14-17)
 ├── interesting orderings: (+1)
 └── scan stock
      ├── columns: s_i_id:1(int!null) s_w_id:2(int!null) s_quantity:3(int) s_dist_05:8(string) s_ytd:14(int) s_order_cnt:15(int) s_remote_cnt:16(int) s_data:17(string)
      ├── constraint: /2/1: [/4/900 - /4/900] [/4/1000 - /4/1000] [/4/1100 - /4/1100] [/4/1400 - /4/1400] [/4/1500 - /4/1500]
      ├── stats: [rows=0.5, distinct(1)=0.5, distinct(2)=0.5]
      ├── cost: 0.625
      ├── key: (1)
      ├── fd: ()-->(2), (1)-->(3,8,14-17)
      ├── ordering: +1 opt(2)
      ├── prune: (1-3,8,14-17)
      └── interesting orderings: (+2,+1) (+1,+2)

# --------------------------------------------------
# 2.5 The Payment Transaction
#
# The Payment business transaction updates the customer's balance and reflects
# the payment on the district and warehouse sales statistics. It represents a
# light-weight, read-write transaction with a high frequency of execution and
# stringent response time requirements to satisfy on-line users. In addition,
# this transaction includes non-primary key access to the CUSTOMER table.
# --------------------------------------------------
opt format=hide-qual
SELECT c_id
FROM customer
WHERE c_w_id = 10 AND c_d_id = 100 AND c_last = 'Smith'
ORDER BY c_first ASC
----
project
 ├── columns: c_id:1(int!null)
 ├── stats: [rows=0.001]
 ├── cost: 0.00111
 ├── key: (1)
 ├── fd: (1)-->(4)
 ├── ordering: +4
 ├── prune: (1,4)
 └── scan customer@customer_idx
      ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_last:6(string!null)
      ├── constraint: /3/2/6/4/1: [/10/100/'Smith' - /10/100/'Smith']
      ├── stats: [rows=0.001, distinct(2)=0.001, distinct(3)=0.001, distinct(6)=0.001]
      ├── cost: 0.0011
      ├── key: (1)
      ├── fd: ()-->(2,3,6), (1)-->(4)
      ├── ordering: +4 opt(2,3,6)
      ├── prune: (1-4,6)
      └── interesting orderings: (+3,+2,+1) (+3,+2,+6,+4,+1)

# --------------------------------------------------
# 2.6 The Order Status Transaction
#
# The Order-Status business transaction queries the status of a customer's last
# order. It represents a mid-weight read-only database transaction with a low
# frequency of execution and response time requirement to satisfy on-line
# users. In addition, this table includes non-primary key access to the
# CUSTOMER table.
# --------------------------------------------------
opt format=hide-qual
SELECT c_balance, c_first, c_middle, c_last
FROM customer
WHERE c_w_id = 10 AND c_d_id = 100 AND c_id = 50
----
project
 ├── columns: c_balance:17(decimal) c_first:4(string) c_middle:5(string) c_last:6(string)
 ├── cardinality: [0 - 1]
 ├── stats: [rows=0.001]
 ├── cost: 0.00129
 ├── key: ()
 ├── fd: ()-->(4-6,17)
 ├── prune: (4-6,17)
 └── scan customer
      ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_middle:5(string) c_last:6(string) c_balance:17(decimal)
      ├── constraint: /3/2/1: [/10/100/50 - /10/100/50]
      ├── cardinality: [0 - 1]
      ├── stats: [rows=0.001, distinct(1)=0.001, distinct(2)=0.001, distinct(3)=0.001]
      ├── cost: 0.00128
      ├── key: ()
      ├── fd: ()-->(1-6,17)
      ├── prune: (1-6,17)
      └── interesting orderings: (+3,+2,+1) (+3,+2,+6,+4,+1)

opt format=hide-qual
SELECT c_id, c_balance, c_first, c_middle
FROM customer
WHERE c_w_id = 10 AND c_d_id = 100 AND c_last = 'Smith'
ORDER BY c_first ASC
----
project
 ├── columns: c_id:1(int!null) c_balance:17(decimal) c_first:4(string) c_middle:5(string)
 ├── stats: [rows=0.001]
 ├── cost: 0.0054
 ├── key: (1)
 ├── fd: (1)-->(4,5,17)
 ├── ordering: +4
 ├── prune: (1,4,5,17)
 └── index-join customer
      ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_middle:5(string) c_last:6(string!null) c_balance:17(decimal)
      ├── stats: [rows=0.001, distinct(2)=0.001, distinct(3)=0.001, distinct(6)=0.001]
      ├── cost: 0.00539
      ├── key: (1)
      ├── fd: ()-->(2,3,6), (1)-->(4,5,17)
      ├── ordering: +4 opt(2,3,6)
      ├── interesting orderings: (+3,+2,+1) (+3,+2,+6,+4,+1)
      └── scan customer@customer_idx
           ├── columns: c_id:1(int!null) c_d_id:2(int!null) c_w_id:3(int!null) c_first:4(string) c_last:6(string!null)
           ├── constraint: /3/2/6/4/1: [/10/100/'Smith' - /10/100/'Smith']
           ├── stats: [rows=0.001, distinct(2)=0.001, distinct(3)=0.001, distinct(6)=0.001]
           ├── cost: 0.0011
           ├── key: (1)
           ├── fd: ()-->(2,3,6), (1)-->(4)
           ├── ordering: +4 opt(2,3,6)
           ├── prune: (1-4,6)
           └── interesting orderings: (+3,+2,+1) (+3,+2,+6,+4,+1)

opt format=hide-qual
SELECT o_id, o_entry_d, o_carrier_id
FROM "order"
WHERE o_w_id = 10 AND o_d_id = 100 AND o_c_id = 50
ORDER BY o_id DESC
LIMIT 1
----
project
 ├── columns: o_id:1(int!null) o_entry_d:5(timestamp) o_carrier_id:6(int)
 ├── cardinality: [0 - 1]
 ├── stats: [rows=0.001]
 ├── cost: 0.00524
 ├── key: ()
 ├── fd: ()-->(1,5,6)
 ├── prune: (1,5,6)
 └── index-join order
      ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_c_id:4(int!null) o_entry_d:5(timestamp) o_carrier_id:6(int)
      ├── cardinality: [0 - 1]
      ├── stats: [rows=0.001]
      ├── cost: 0.00523
      ├── key: ()
      ├── fd: ()-->(1-6)
      ├── interesting orderings: (+3,+2,-1) (+3,+2,+4,+1)
      └── scan order@secondary,rev
           ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_c_id:4(int!null)
           ├── constraint: /3/2/4/1: [/10/100/50 - /10/100/50]
           ├── limit: 1(rev)
           ├── stats: [rows=0.001, distinct(2)=0.001, distinct(3)=0.001, distinct(4)=0.001]
           ├── cost: 0.00108
           ├── key: ()
           ├── fd: ()-->(1-4)
           ├── prune: (1-4)
           └── interesting orderings: (+3,+2,-1) (+3,+2,+4,+1)

opt format=hide-qual
SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d
FROM order_line
WHERE ol_w_id = 10 AND ol_d_id = 100 AND ol_o_id = 1000
----
project
 ├── columns: ol_i_id:5(int!null) ol_supply_w_id:6(int) ol_quantity:8(int) ol_amount:9(decimal) ol_delivery_d:7(timestamp)
 ├── stats: [rows=0.001]
 ├── cost: 0.00119
 ├── prune: (5-9)
 ├── interesting orderings: (+6)
 └── scan order_line
      ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) ol_supply_w_id:6(int) ol_delivery_d:7(timestamp) ol_quantity:8(int) ol_amount:9(decimal)
      ├── constraint: /3/2/-1/4: [/10/100/1000 - /10/100/1000]
      ├── stats: [rows=0.001, distinct(1)=0.001, distinct(2)=0.001, distinct(3)=0.001]
      ├── cost: 0.00118
      ├── fd: ()-->(1-3)
      ├── prune: (1-3,5-9)
      └── interesting orderings: (+3,+2,-1) (+6,+2,+3,+1)

# --------------------------------------------------
# 2.7 The Delivery Transaction
#
# The Delivery business transaction consists of processing a batch of 10 new
# (not yet delivered) orders. Each order is processed (delivered) in full
# within the scope of a read-write database transaction. The number of orders
# delivered as a group (or batched) within the same database transaction is
# implementation specific. The business transaction, comprised of one or more
# (up to 10) database transactions, has a low frequency of execution and must
# complete within a relaxed response time requirement.
#
# The Delivery transaction is intended to be executed in deferred mode through
# a queuing mechanism, rather than interactively, with terminal response
# indicating transaction completion. The result of the deferred execution is
# recorded into a result file.
# --------------------------------------------------
opt format=hide-qual
SELECT no_o_id
FROM new_order
WHERE no_w_id = 10 AND no_d_id = 100
ORDER BY no_o_id ASC
LIMIT 1
----
project
 ├── columns: no_o_id:1(int!null)
 ├── cardinality: [0 - 1]
 ├── stats: [rows=0.1]
 ├── cost: 0.107
 ├── key: ()
 ├── fd: ()-->(1)
 ├── prune: (1)
 └── scan new_order,rev
      ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null)
      ├── constraint: /3/2/-1: [/10/100 - /10/100]
      ├── limit: 1(rev)
      ├── stats: [rows=0.1]
      ├── cost: 0.106
      ├── key: ()
      ├── fd: ()-->(1-3)
      ├── prune: (1-3)
      └── interesting orderings: (+3,+2,-1)

opt format=hide-qual
SELECT sum(ol_amount)
FROM order_line
WHERE ol_w_id = 10 AND ol_d_id = 100 AND ol_o_id = 1000
----
scalar-group-by
 ├── columns: sum:11(decimal)
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 0.01115
 ├── key: ()
 ├── fd: ()-->(11)
 ├── prune: (11)
 ├── scan order_line
 │    ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_amount:9(decimal)
 │    ├── constraint: /3/2/-1/4: [/10/100/1000 - /10/100/1000]
 │    ├── stats: [rows=0.001, distinct(1)=0.001, distinct(2)=0.001, distinct(3)=0.001]
 │    ├── cost: 0.00114
 │    ├── fd: ()-->(1-3)
 │    ├── prune: (1-3,9)
 │    └── interesting orderings: (+3,+2,-1)
 └── aggregations [outer=(9)]
      └── sum [type=decimal, outer=(9)]
           └── variable: ol_amount [type=decimal, outer=(9)]

# --------------------------------------------------
# 2.8 The Stock-Level Transaction
#
# The Stock-Level business transaction determines the number of recently sold
# items that have a stock level below a specified threshold. It represents a
# heavy read-only database transaction with a low frequency of execution, a
# relaxed response time requirement, and relaxed consistency requirements.
# --------------------------------------------------
opt format=hide-qual
SELECT d_next_o_id
FROM district
WHERE d_w_id = 10 AND d_id = 100
----
project
 ├── columns: d_next_o_id:11(int)
 ├── cardinality: [0 - 1]
 ├── stats: [rows=0.1]
 ├── cost: 0.115
 ├── key: ()
 ├── fd: ()-->(11)
 ├── prune: (11)
 └── scan district
      ├── columns: d_id:1(int!null) d_w_id:2(int!null) d_next_o_id:11(int)
      ├── constraint: /2/1: [/10/100 - /10/100]
      ├── cardinality: [0 - 1]
      ├── stats: [rows=0.1, distinct(1)=0.1, distinct(2)=0.1]
      ├── cost: 0.114
      ├── key: ()
      ├── fd: ()-->(1,2,11)
      ├── prune: (1,2,11)
      └── interesting orderings: (+2,+1)

opt format=hide-qual
SELECT count(DISTINCT s_i_id)
FROM order_line
JOIN stock
ON s_i_id=ol_i_id AND s_w_id=ol_w_id
WHERE ol_w_id = 10
    AND ol_d_id = 100
    AND ol_o_id BETWEEN 1000 - 20 AND 1000 - 1
    AND s_quantity < 15
----
scalar-group-by
 ├── columns: count:28(int)
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 0.193466667
 ├── key: ()
 ├── fd: ()-->(28)
 ├── prune: (28)
 ├── inner-join (lookup stock)
 │    ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null) s_i_id:11(int!null) s_w_id:12(int!null) s_quantity:13(int!null)
 │    ├── key columns: [3 5] = [12 11]
 │    ├── stats: [rows=0.0666666667, distinct(3)=0.02, distinct(5)=0.0199982001, distinct(11)=0.0199982001, distinct(12)=0.02]
 │    ├── cost: 0.1828
 │    ├── fd: ()-->(2,3,12), (11)-->(13), (5)==(11), (11)==(5), (3)==(12), (12)==(3)
 │    ├── interesting orderings: (+3,+2,-1)
 │    ├── scan order_line
 │    │    ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) ol_i_id:5(int!null)
 │    │    ├── constraint: /3/2/-1/4: [/10/100/999 - /10/100/980]
 │    │    ├── stats: [rows=0.02, distinct(1)=0.02, distinct(2)=0.02, distinct(3)=0.02, distinct(5)=0.0199982001]
 │    │    ├── cost: 0.0228
 │    │    ├── fd: ()-->(2,3)
 │    │    ├── prune: (5)
 │    │    └── interesting orderings: (+3,+2,-1)
 │    └── filters [type=bool, outer=(12,13), constraints=(/12: [/10 - /10]; /13: (/NULL - /14]; tight), fd=()-->(12)]
 │         ├── eq [type=bool, outer=(12), constraints=(/12: [/10 - /10]; tight)]
 │         │    ├── variable: s_w_id [type=int, outer=(12)]
 │         │    └── const: 10 [type=int]
 │         └── lt [type=bool, outer=(13), constraints=(/13: (/NULL - /14]; tight)]
 │              ├── variable: s_quantity [type=int, outer=(13)]
 │              └── const: 15 [type=int]
 └── aggregations [outer=(11)]
      └── count [type=int, outer=(11)]
           └── agg-distinct [type=int, outer=(11)]
                └── variable: s_i_id [type=int, outer=(11)]

# --------------------------------------------------
# Consistency Queries
#
# These queries run after TPCC in order to check database consistency.
# They are not part of the benchmark itself.
# --------------------------------------------------
opt format=hide-qual
SELECT count(*)
FROM warehouse
FULL OUTER JOIN
(
    SELECT d_w_id, sum(d_ytd) as sum_d_ytd
    FROM district
    GROUP BY d_w_id
)
ON (w_id = d_w_id)
WHERE w_ytd != sum_d_ytd
----
scalar-group-by
 ├── columns: count:22(int)
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 1588.34333
 ├── key: ()
 ├── fd: ()-->(22)
 ├── prune: (22)
 ├── inner-join (lookup warehouse)
 │    ├── columns: w_id:1(int!null) w_ytd:9(decimal!null) d_w_id:11(int!null) sum:21(decimal!null)
 │    ├── key columns: [11] = [1]
 │    ├── stats: [rows=33.3333333, distinct(1)=33.3333333, distinct(11)=33.3333333]
 │    ├── cost: 1588
 │    ├── key: (11)
 │    ├── fd: (1)-->(9), (11)-->(21), (1)==(11), (11)==(1)
 │    ├── interesting orderings: (+11)
 │    ├── group-by
 │    │    ├── columns: d_w_id:11(int!null) sum:21(decimal)
 │    │    ├── grouping columns: d_w_id:11(int!null)
 │    │    ├── internal-ordering: +11
 │    │    ├── stats: [rows=100, distinct(11)=100]
 │    │    ├── cost: 1151
 │    │    ├── key: (11)
 │    │    ├── fd: (11)-->(21)
 │    │    ├── prune: (21)
 │    │    ├── interesting orderings: (+11)
 │    │    ├── scan district
 │    │    │    ├── columns: d_w_id:11(int!null) d_ytd:19(decimal)
 │    │    │    ├── stats: [rows=1000, distinct(11)=100]
 │    │    │    ├── cost: 1130
 │    │    │    ├── ordering: +11
 │    │    │    ├── prune: (11,19)
 │    │    │    └── interesting orderings: (+11)
 │    │    └── aggregations [outer=(19)]
 │    │         └── sum [type=decimal, outer=(19)]
 │    │              └── variable: d_ytd [type=decimal, outer=(19)]
 │    └── filters [type=bool, outer=(9,21), constraints=(/9: (/NULL - ]; /21: (/NULL - ])]
 │         └── ne [type=bool, outer=(9,21), constraints=(/9: (/NULL - ]; /21: (/NULL - ])]
 │              ├── variable: w_ytd [type=decimal, outer=(9)]
 │              └── variable: sum [type=decimal, outer=(21)]
 └── aggregations
      └── count-rows [type=int]

opt format=hide-qual
SELECT d_next_o_id
FROM district
ORDER BY d_w_id, d_id
----
scan district
 ├── columns: d_next_o_id:11(int)
 ├── stats: [rows=1000]
 ├── cost: 1140
 ├── key: (1,2)
 ├── fd: (1,2)-->(11)
 ├── ordering: +2,+1
 ├── prune: (1,2,11)
 └── interesting orderings: (+2,+1)

opt format=hide-qual
SELECT max(no_o_id)
FROM new_order
GROUP BY no_d_id, no_w_id
ORDER BY no_w_id, no_d_id
----
group-by
 ├── columns: max:4(int)
 ├── grouping columns: no_d_id:2(int!null) no_w_id:3(int!null)
 ├── stats: [rows=1000, distinct(2,3)=1000]
 ├── cost: 1100
 ├── key: (2,3)
 ├── fd: (2,3)-->(4)
 ├── ordering: +3,+2
 ├── prune: (4)
 ├── interesting orderings: (+3,+2)
 ├── scan new_order
 │    ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null)
 │    ├── stats: [rows=1000, distinct(2,3)=1000]
 │    ├── cost: 1060
 │    ├── key: (1-3)
 │    ├── ordering: +3,+2
 │    ├── prune: (1-3)
 │    └── interesting orderings: (+3,+2,-1)
 └── aggregations [outer=(1)]
      └── max [type=int, outer=(1)]
           └── variable: no_o_id [type=int, outer=(1)]

opt format=hide-qual
SELECT max(o_id)
FROM "order"
GROUP BY o_d_id, o_w_id
ORDER BY o_w_id, o_d_id
----
group-by
 ├── columns: max:9(int)
 ├── grouping columns: o_d_id:2(int!null) o_w_id:3(int!null)
 ├── stats: [rows=1000, distinct(2,3)=1000]
 ├── cost: 1110
 ├── key: (2,3)
 ├── fd: (2,3)-->(9)
 ├── ordering: +3,+2
 ├── prune: (9)
 ├── interesting orderings: (+3,+2)
 ├── scan order@order_idx
 │    ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null)
 │    ├── stats: [rows=1000, distinct(2,3)=1000]
 │    ├── cost: 1070
 │    ├── key: (1-3)
 │    ├── ordering: +3,+2
 │    ├── prune: (1-3)
 │    └── interesting orderings: (+3,+2,-1)
 └── aggregations [outer=(1)]
      └── max [type=int, outer=(1)]
           └── variable: o_id [type=int, outer=(1)]

opt format=hide-qual
SELECT count(*)
FROM
(
    SELECT max(no_o_id) - min(no_o_id) - count(*) AS nod
    FROM new_order
    GROUP BY no_w_id, no_d_id
)
WHERE nod != -1
----
scalar-group-by
 ├── columns: count:8(int)
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 1133.34333
 ├── key: ()
 ├── fd: ()-->(8)
 ├── prune: (8)
 ├── select
 │    ├── columns: no_d_id:2(int!null) no_w_id:3(int!null) max:4(int) min:5(int) count_rows:6(int)
 │    ├── stats: [rows=333.333333]
 │    ├── cost: 1130
 │    ├── key: (2,3)
 │    ├── fd: (2,3)-->(4-6)
 │    ├── interesting orderings: (+3,+2)
 │    ├── group-by
 │    │    ├── columns: no_d_id:2(int!null) no_w_id:3(int!null) max:4(int) min:5(int) count_rows:6(int)
 │    │    ├── grouping columns: no_d_id:2(int!null) no_w_id:3(int!null)
 │    │    ├── internal-ordering: +3,+2
 │    │    ├── stats: [rows=1000, distinct(2,3)=1000]
 │    │    ├── cost: 1120
 │    │    ├── key: (2,3)
 │    │    ├── fd: (2,3)-->(4-6)
 │    │    ├── prune: (4-6)
 │    │    ├── interesting orderings: (+3,+2)
 │    │    ├── scan new_order
 │    │    │    ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null)
 │    │    │    ├── stats: [rows=1000, distinct(2,3)=1000]
 │    │    │    ├── cost: 1060
 │    │    │    ├── key: (1-3)
 │    │    │    ├── ordering: +3,+2
 │    │    │    ├── prune: (1-3)
 │    │    │    └── interesting orderings: (+3,+2,-1)
 │    │    └── aggregations [outer=(1)]
 │    │         ├── max [type=int, outer=(1)]
 │    │         │    └── variable: no_o_id [type=int, outer=(1)]
 │    │         ├── min [type=int, outer=(1)]
 │    │         │    └── variable: no_o_id [type=int, outer=(1)]
 │    │         └── count-rows [type=int]
 │    └── filters [type=bool, outer=(4-6)]
 │         └── ne [type=bool, outer=(4-6)]
 │              ├── minus [type=int, outer=(4-6)]
 │              │    ├── minus [type=int, outer=(4,5)]
 │              │    │    ├── variable: max [type=int, outer=(4)]
 │              │    │    └── variable: min [type=int, outer=(5)]
 │              │    └── variable: count_rows [type=int, outer=(6)]
 │              └── const: -1 [type=int]
 └── aggregations
      └── count-rows [type=int]

opt format=hide-qual
SELECT sum(o_ol_cnt)
FROM "order"
GROUP BY o_w_id, o_d_id
ORDER BY o_w_id, o_d_id
----
group-by
 ├── columns: sum:9(decimal)
 ├── grouping columns: o_d_id:2(int!null) o_w_id:3(int!null)
 ├── stats: [rows=1000, distinct(2,3)=1000]
 ├── cost: 1150
 ├── key: (2,3)
 ├── fd: (2,3)-->(9)
 ├── ordering: +3,+2
 ├── prune: (9)
 ├── interesting orderings: (+3,+2)
 ├── scan order
 │    ├── columns: o_d_id:2(int!null) o_w_id:3(int!null) o_ol_cnt:7(int)
 │    ├── stats: [rows=1000, distinct(2,3)=1000]
 │    ├── cost: 1110
 │    ├── ordering: +3,+2
 │    ├── prune: (2,3,7)
 │    └── interesting orderings: (+3,+2)
 └── aggregations [outer=(7)]
      └── sum [type=decimal, outer=(7)]
           └── variable: o_ol_cnt [type=int, outer=(7)]

opt format=hide-qual
SELECT count(*)
FROM order_line
GROUP BY ol_w_id, ol_d_id
ORDER BY ol_w_id, ol_d_id
----
group-by
 ├── columns: count:11(int)
 ├── grouping columns: ol_d_id:2(int!null) ol_w_id:3(int!null)
 ├── stats: [rows=1000, distinct(2,3)=1000]
 ├── cost: 1160
 ├── key: (2,3)
 ├── fd: (2,3)-->(11)
 ├── ordering: +3,+2
 ├── prune: (11)
 ├── interesting orderings: (+3,+2)
 ├── scan order_line
 │    ├── columns: ol_d_id:2(int!null) ol_w_id:3(int!null)
 │    ├── stats: [rows=1000, distinct(2,3)=1000]
 │    ├── cost: 1120
 │    ├── ordering: +3,+2
 │    ├── prune: (2,3)
 │    └── interesting orderings: (+3,+2)
 └── aggregations
      └── count-rows [type=int]

opt format=hide-qual
(SELECT no_w_id, no_d_id, no_o_id FROM new_order)
EXCEPT ALL
(SELECT o_w_id, o_d_id, o_id FROM "order" WHERE o_carrier_id IS NULL)
----
except-all
 ├── columns: no_w_id:3(int!null) no_d_id:2(int!null) no_o_id:1(int!null)
 ├── left columns: no_w_id:3(int!null) no_d_id:2(int!null) no_o_id:1(int!null)
 ├── right columns: o_w_id:6(int) o_d_id:5(int) o_id:4(int)
 ├── stats: [rows=1000]
 ├── cost: 2170.2
 ├── scan new_order
 │    ├── columns: no_o_id:1(int!null) no_d_id:2(int!null) no_w_id:3(int!null)
 │    ├── stats: [rows=1000]
 │    ├── cost: 1060
 │    ├── key: (1-3)
 │    ├── prune: (1-3)
 │    └── interesting orderings: (+3,+2,-1)
 └── project
      ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null)
      ├── stats: [rows=10]
      ├── cost: 1090.1
      ├── key: (4-6)
      ├── prune: (4-6)
      ├── interesting orderings: (+6,+5,-4)
      └── select
           ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) o_carrier_id:9(int)
           ├── stats: [rows=10, distinct(9)=1]
           ├── cost: 1090
           ├── key: (4-6)
           ├── fd: ()-->(9)
           ├── prune: (4-6)
           ├── interesting orderings: (+6,+5,-4) (+6,+5,+9,+4)
           ├── scan order@order_idx
           │    ├── columns: o_id:4(int!null) o_d_id:5(int!null) o_w_id:6(int!null) o_carrier_id:9(int)
           │    ├── stats: [rows=1000, distinct(9)=100]
           │    ├── cost: 1080
           │    ├── key: (4-6)
           │    ├── fd: (4-6)-->(9)
           │    ├── prune: (4-6,9)
           │    └── interesting orderings: (+6,+5,-4) (+6,+5,+9,+4)
           └── filters [type=bool, outer=(9), constraints=(/9: [/NULL - /NULL]; tight), fd=()-->(9)]
                └── is [type=bool, outer=(9), constraints=(/9: [/NULL - /NULL]; tight)]
                     ├── variable: o_carrier_id [type=int, outer=(9)]
                     └── null [type=unknown]

opt format=hide-qual
(SELECT o_w_id, o_d_id, o_id FROM "order" WHERE o_carrier_id IS NULL)
EXCEPT ALL
(SELECT no_w_id, no_d_id, no_o_id FROM new_order)
----
except-all
 ├── columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null)
 ├── left columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null)
 ├── right columns: no_w_id:11(int) no_d_id:10(int) no_o_id:9(int)
 ├── stats: [rows=10]
 ├── cost: 2160.3
 ├── project
 │    ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null)
 │    ├── stats: [rows=10]
 │    ├── cost: 1090.1
 │    ├── key: (1-3)
 │    ├── prune: (1-3)
 │    ├── interesting orderings: (+3,+2,-1)
 │    └── select
 │         ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int)
 │         ├── stats: [rows=10, distinct(6)=1]
 │         ├── cost: 1090
 │         ├── key: (1-3)
 │         ├── fd: ()-->(6)
 │         ├── prune: (1-3)
 │         ├── interesting orderings: (+3,+2,-1) (+3,+2,+6,+1)
 │         ├── scan order@order_idx
 │         │    ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int)
 │         │    ├── stats: [rows=1000, distinct(6)=100]
 │         │    ├── cost: 1080
 │         │    ├── key: (1-3)
 │         │    ├── fd: (1-3)-->(6)
 │         │    ├── prune: (1-3,6)
 │         │    └── interesting orderings: (+3,+2,-1) (+3,+2,+6,+1)
 │         └── filters [type=bool, outer=(6), constraints=(/6: [/NULL - /NULL]; tight), fd=()-->(6)]
 │              └── is [type=bool, outer=(6), constraints=(/6: [/NULL - /NULL]; tight)]
 │                   ├── variable: o_carrier_id [type=int, outer=(6)]
 │                   └── null [type=unknown]
 └── scan new_order
      ├── columns: no_o_id:9(int!null) no_d_id:10(int!null) no_w_id:11(int!null)
      ├── stats: [rows=1000]
      ├── cost: 1060
      ├── key: (9-11)
      ├── prune: (9-11)
      └── interesting orderings: (+11,+10,-9)

opt format=hide-qual
(
    SELECT o_w_id, o_d_id, o_id, o_ol_cnt
    FROM "order"
    ORDER BY o_w_id, o_d_id, o_id DESC
)
EXCEPT ALL
(
    SELECT ol_w_id, ol_d_id, ol_o_id, count(*)
    FROM order_line
    GROUP BY (ol_w_id, ol_d_id, ol_o_id)
    ORDER BY ol_w_id, ol_d_id, ol_o_id DESC
)
----
except-all
 ├── columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null) o_ol_cnt:7(int)
 ├── left columns: o_w_id:3(int!null) o_d_id:2(int!null) o_id:1(int!null) o_ol_cnt:7(int)
 ├── right columns: ol_w_id:11(int) ol_d_id:10(int) ol_o_id:9(int) count_rows:19(int)
 ├── stats: [rows=1000]
 ├── cost: 2290
 ├── scan order
 │    ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_ol_cnt:7(int)
 │    ├── stats: [rows=1000]
 │    ├── cost: 1120
 │    ├── key: (1-3)
 │    ├── fd: (1-3)-->(7)
 │    ├── prune: (1-3,7)
 │    └── interesting orderings: (+3,+2,-1)
 └── group-by
      ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) count_rows:19(int)
      ├── grouping columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null)
      ├── stats: [rows=1000, distinct(9-11)=1000]
      ├── cost: 1140
      ├── key: (9-11)
      ├── fd: (9-11)-->(19)
      ├── prune: (19)
      ├── interesting orderings: (+11,+10,-9)
      ├── scan order_line@order_line_fk
      │    ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null)
      │    ├── stats: [rows=1000, distinct(9-11)=1000]
      │    ├── cost: 1080
      │    ├── prune: (9-11)
      │    └── interesting orderings: (+11,+10,-9)
      └── aggregations
           └── count-rows [type=int]

opt format=hide-qual
(
    SELECT ol_w_id, ol_d_id, ol_o_id, count(*)
    FROM order_line
    GROUP BY (ol_w_id, ol_d_id, ol_o_id)
    ORDER BY ol_w_id, ol_d_id, ol_o_id DESC
)
EXCEPT ALL
(
    SELECT o_w_id, o_d_id, o_id, o_ol_cnt
    FROM "order"
    ORDER BY o_w_id, o_d_id, o_id DESC
)
----
except-all
 ├── columns: ol_w_id:3(int!null) ol_d_id:2(int!null) ol_o_id:1(int!null) count:11(int)
 ├── left columns: ol_w_id:3(int!null) ol_d_id:2(int!null) ol_o_id:1(int!null) count_rows:11(int)
 ├── right columns: o_w_id:14(int) o_d_id:13(int) o_id:12(int) o_ol_cnt:18(int)
 ├── stats: [rows=1000]
 ├── cost: 2290
 ├── group-by
 │    ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null) count_rows:11(int)
 │    ├── grouping columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null)
 │    ├── stats: [rows=1000, distinct(1-3)=1000]
 │    ├── cost: 1140
 │    ├── key: (1-3)
 │    ├── fd: (1-3)-->(11)
 │    ├── prune: (11)
 │    ├── interesting orderings: (+3,+2,-1)
 │    ├── scan order_line@order_line_fk
 │    │    ├── columns: ol_o_id:1(int!null) ol_d_id:2(int!null) ol_w_id:3(int!null)
 │    │    ├── stats: [rows=1000, distinct(1-3)=1000]
 │    │    ├── cost: 1080
 │    │    ├── prune: (1-3)
 │    │    └── interesting orderings: (+3,+2,-1)
 │    └── aggregations
 │         └── count-rows [type=int]
 └── scan order
      ├── columns: o_id:12(int!null) o_d_id:13(int!null) o_w_id:14(int!null) o_ol_cnt:18(int)
      ├── stats: [rows=1000]
      ├── cost: 1120
      ├── key: (12-14)
      ├── fd: (12-14)-->(18)
      ├── prune: (12-14,18)
      └── interesting orderings: (+14,+13,-12)

opt format=hide-qual
SELECT count(*)
FROM
(
    SELECT o_w_id, o_d_id, o_id
    FROM "order"
    WHERE o_carrier_id IS NULL
)
FULL OUTER JOIN
(
    SELECT ol_w_id, ol_d_id, ol_o_id
    FROM order_line
    WHERE ol_delivery_d IS NULL
)
ON (ol_w_id = o_w_id AND ol_d_id = o_d_id AND ol_o_id = o_id)
WHERE ol_o_id IS NULL OR o_id IS NULL
----
scalar-group-by
 ├── columns: count:19(int)
 ├── cardinality: [1 - 1]
 ├── stats: [rows=1]
 ├── cost: 2240.974
 ├── key: ()
 ├── fd: ()-->(19)
 ├── prune: (19)
 ├── select
 │    ├── columns: o_id:1(int) o_d_id:2(int) o_w_id:3(int) ol_o_id:9(int) ol_d_id:10(int) ol_w_id:11(int)
 │    ├── stats: [rows=6.62853719]
 │    ├── cost: 2240.89771
 │    ├── interesting orderings: (+3,+2,-1) (+11,+10,-9)
 │    ├── full-join
 │    │    ├── columns: o_id:1(int) o_d_id:2(int) o_w_id:3(int) ol_o_id:9(int) ol_d_id:10(int) ol_w_id:11(int)
 │    │    ├── stats: [rows=19.8856116]
 │    │    ├── cost: 2240.69886
 │    │    ├── reject-nulls: (1-3,9-11)
 │    │    ├── interesting orderings: (+3,+2,-1) (+11,+10,-9)
 │    │    ├── project
 │    │    │    ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null)
 │    │    │    ├── stats: [rows=10, distinct(1)=9.5617925, distinct(2)=9.5617925, distinct(3)=9.5617925]
 │    │    │    ├── cost: 1090.1
 │    │    │    ├── key: (1-3)
 │    │    │    ├── prune: (1-3)
 │    │    │    ├── interesting orderings: (+3,+2,-1)
 │    │    │    └── select
 │    │    │         ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int)
 │    │    │         ├── stats: [rows=10, distinct(1)=9.5617925, distinct(2)=9.5617925, distinct(3)=9.5617925, distinct(6)=1]
 │    │    │         ├── cost: 1090
 │    │    │         ├── key: (1-3)
 │    │    │         ├── fd: ()-->(6)
 │    │    │         ├── prune: (1-3)
 │    │    │         ├── interesting orderings: (+3,+2,-1) (+3,+2,+6,+1)
 │    │    │         ├── scan order@order_idx
 │    │    │         │    ├── columns: o_id:1(int!null) o_d_id:2(int!null) o_w_id:3(int!null) o_carrier_id:6(int)
 │    │    │         │    ├── stats: [rows=1000, distinct(1)=100, distinct(2)=100, distinct(3)=100, distinct(6)=100]
 │    │    │         │    ├── cost: 1080
 │    │    │         │    ├── key: (1-3)
 │    │    │         │    ├── fd: (1-3)-->(6)
 │    │    │         │    ├── prune: (1-3,6)
 │    │    │         │    └── interesting orderings: (+3,+2,-1) (+3,+2,+6,+1)
 │    │    │         └── filters [type=bool, outer=(6), constraints=(/6: [/NULL - /NULL]; tight), fd=()-->(6)]
 │    │    │              └── is [type=bool, outer=(6), constraints=(/6: [/NULL - /NULL]; tight)]
 │    │    │                   ├── variable: o_carrier_id [type=int, outer=(6)]
 │    │    │                   └── null [type=unknown]
 │    │    ├── project
 │    │    │    ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null)
 │    │    │    ├── stats: [rows=10, distinct(9)=9.5617925, distinct(10)=9.5617925, distinct(11)=9.5617925]
 │    │    │    ├── cost: 1150.1
 │    │    │    ├── prune: (9-11)
 │    │    │    ├── interesting orderings: (+11,+10,-9)
 │    │    │    └── select
 │    │    │         ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ol_delivery_d:15(timestamp)
 │    │    │         ├── stats: [rows=10, distinct(9)=9.5617925, distinct(10)=9.5617925, distinct(11)=9.5617925, distinct(15)=1]
 │    │    │         ├── cost: 1150
 │    │    │         ├── fd: ()-->(15)
 │    │    │         ├── prune: (9-11)
 │    │    │         ├── interesting orderings: (+11,+10,-9)
 │    │    │         ├── scan order_line
 │    │    │         │    ├── columns: ol_o_id:9(int!null) ol_d_id:10(int!null) ol_w_id:11(int!null) ol_delivery_d:15(timestamp)
 │    │    │         │    ├── stats: [rows=1000, distinct(9)=100, distinct(10)=100, distinct(11)=100, distinct(15)=100]
 │    │    │         │    ├── cost: 1140
 │    │    │         │    ├── prune: (9-11,15)
 │    │    │         │    └── interesting orderings: (+11,+10,-9)
 │    │    │         └── filters [type=bool, outer=(15), constraints=(/15: [/NULL - /NULL]; tight), fd=()-->(15)]
 │    │    │              └── is [type=bool, outer=(15), constraints=(/15: [/NULL - /NULL]; tight)]
 │    │    │                   ├── variable: ol_delivery_d [type=timestamp, outer=(15)]
 │    │    │                   └── null [type=unknown]
 │    │    └── filters [type=bool, outer=(1-3,9-11), constraints=(/1: (/NULL - ]; /2: (/NULL - ]; /3: (/NULL - ]; /9: (/NULL - ]; /10: (/NULL - ]; /11: (/NULL - ]), fd=(3)==(11), (11)==(3), (2)==(10), (10)==(2), (1)==(9), (9)==(1)]
 │    │         ├── eq [type=bool, outer=(3,11), constraints=(/3: (/NULL - ]; /11: (/NULL - ])]
 │    │         │    ├── variable: ol_w_id [type=int, outer=(11)]
 │    │         │    └── variable: o_w_id [type=int, outer=(3)]
 │    │         ├── eq [type=bool, outer=(2,10), constraints=(/2: (/NULL - ]; /10: (/NULL - ])]
 │    │         │    ├── variable: ol_d_id [type=int, outer=(10)]
 │    │         │    └── variable: o_d_id [type=int, outer=(2)]
 │    │         └── eq [type=bool, outer=(1,9), constraints=(/1: (/NULL - ]; /9: (/NULL - ])]
 │    │              ├── variable: ol_o_id [type=int, outer=(9)]
 │    │              └── variable: o_id [type=int, outer=(1)]
 │    └── filters [type=bool, outer=(1,9)]
 │         └── or [type=bool, outer=(1,9)]
 │              ├── is [type=bool, outer=(9)]
 │              │    ├── variable: ol_o_id [type=int, outer=(9)]
 │              │    └── null [type=unknown]
 │              └── is [type=bool, outer=(1)]
 │                   ├── variable: o_id [type=int, outer=(1)]
 │                   └── null [type=unknown]
 └── aggregations
      └── count-rows [type=int]
