Skip to content

Instantly share code, notes, and snippets.

@spetrunia
Created February 8, 2023 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spetrunia/bef22d46dd95b0da4f0885fa86706b60 to your computer and use it in GitHub Desktop.
Save spetrunia/bef22d46dd95b0da4f0885fa86706b60 to your computer and use it in GitHub Desktop.
MariaDB [test]> explain SELECT SUM( l_partkey ) FROM region JOIN nation ON ( r_regionkey = n_regionkey ) LEFT JOIN supplier ON ( s_nationkey = n_nationkey ) JOIN partsupp ON ( s_suppkey = ps_suppkey ) RIGHT JOIN lineitem ON ( ps_partkey = l_partkey AND ps_suppkey = l_suppkey ) JOIN orders ON ( l_orderkey = o_orderkey ) WHERE o_comment IS NOT NULL OR n_comment IS NOT NULL AND ps_availqty = l_quantity\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: orders
type: ALL
possible_keys: PRIMARY
key: NULL
key_len: NULL
ref: NULL
rows: 150
Extra:
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: lineitem
type: hash_ALL
possible_keys: PRIMARY,i_l_orderkey,i_l_orderkey_quantity
key: #hash#PRIMARY
key_len: 4
ref: test.orders.o_orderkey
rows: 586
Extra: Using join buffer (flat, BNLH join)
*************************** 3. row ***************************
id: 1
select_type: SIMPLE
table: supplier
type: hash_index
possible_keys: PRIMARY,i_s_nationkey
key: #hash#PRIMARY:i_s_nationkey
key_len: 4:5
ref: test.lineitem.l_suppkey
rows: 1
Extra: Using where; Using index
*************************** 4. row ***************************
id: 1
select_type: SIMPLE
table: nation
type: hash_ALL
possible_keys: PRIMARY,i_n_regionkey
key: #hash#PRIMARY
key_len: 4
ref: test.supplier.s_nationkey
rows: 25
Extra: Using where
*************************** 5. row ***************************
id: 1
select_type: SIMPLE
table: partsupp
type: hash_ALL
possible_keys: PRIMARY,i_ps_partkey,i_ps_suppkey
key: #hash#PRIMARY
key_len: 8
ref: test.lineitem.l_partkey,test.lineitem.l_suppkey
rows: 20
Extra: Using where
*************************** 6. row ***************************
id: 1
select_type: SIMPLE
table: region
type: hash_ALL
possible_keys: PRIMARY
key: #hash#PRIMARY
key_len: 4
ref: test.nation.n_regionkey
rows: 5
Extra:
6 rows in set (0.007 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment