This statement creates a join index defined with a multiway join result:
CREATE JOIN INDEX cust_order_join_line AS SELECT (l_orderkey, o_orderdate, c_nationkey, o_totalprice), (l_partkey, l_quantity, l_extendedprice, l_shipdate) FROM (lineitem LEFT JOIN orders ON l_orderkey = o_orderkey) INNER JOIN customer ON o_custkey = c_custkey PRIMARY INDEX (l_orderkey);
The following query is provided as an example to show how the Optimizer uses the join index to process a query on the base tables for which it is defined. An EXPLAIN of the SELECT statement includes RETRIEVE step from join index table cust_order_join_line by way of an all-rows scan with a condition of ("cust_order_join_line.c_nationkey = 10").
SELECT l_orderkey, o_orderdate, o_totalprice, l_partkey, l_quantity, l_extendedprice, l_shipdate FROM lineitem, orders, customer WHERE l_orderkey = o_orderkey AND o_custkey = c_custkey AND c_nationkey = 10;