select 'We are in the ' || current_database() || ' database';
select 'Iteration 1';
select $$select enable_hashjoin_usestatmcvs = 'on';$$;
set enable_hashjoin_usestatmcvs = 'on';
select $$SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$set enable_hashjoin_usestatmcvs = 'off';$$;
set enable_hashjoin_usestatmcvs = 'off';
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;

select 'Iteration 2';
select $$select enable_hashjoin_usestatmcvs = 'on';$$;
set enable_hashjoin_usestatmcvs = 'on';
select $$SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$set enable_hashjoin_usestatmcvs = 'off';$$;
set enable_hashjoin_usestatmcvs = 'off';
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;

select 'Iteration 3';
select $$select enable_hashjoin_usestatmcvs = 'on';$$;
set enable_hashjoin_usestatmcvs = 'on';
select $$SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$set enable_hashjoin_usestatmcvs = 'off';$$;
set enable_hashjoin_usestatmcvs = 'off';
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;

select 'Iteration 4';
select $$select enable_hashjoin_usestatmcvs = 'on';$$;
set enable_hashjoin_usestatmcvs = 'on';
select $$SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$set enable_hashjoin_usestatmcvs = 'off';$$;
set enable_hashjoin_usestatmcvs = 'off';
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;

select 'Iteration 5';
select $$select enable_hashjoin_usestatmcvs = 'on';$$;
set enable_hashjoin_usestatmcvs = 'on';
select $$SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$set enable_hashjoin_usestatmcvs = 'off';$$;
set enable_hashjoin_usestatmcvs = 'off';
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem WHERE p_partkey = l_partkey;
select $$EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT * FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;
select $$EXPLAIN ANALYZE SELECT count(*) FROM Part, Lineitem, Supplier WHERE p_partkey = l_partkey and s_suppkey = l_suppkey;$$;
EXPLAIN ANALYZE SELECT * FROM Supplier, Lineitem WHERE s_suppkey = l_suppkey;

