Commit 9e307a7e authored by Marcel Huber's avatar Marcel Huber
Browse files

ColumnStore queries and logs updated

- adjusted pg indexes where required
- similar to pg, the query on monetdb will also be executed twice
parent 462f61de
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -14,7 +14,30 @@ SET track_counts TO false;
-- columns is in effect when using wrapped mode
\pset columns 0
\c ds2 ds2
CREATE INDEX categories_category_categoryname ON categories(category,categoryname);
CREATE INDEX categories_category ON categories(category);
CREATE INDEX customers_age_lastname_firstname ON customers(age,lastname,firstname);
CREATE INDEX customers_city_customerid_income ON customers(city,customerid,income);
CREATE INDEX customers_city_customerid ON customers(city,customerid);
CREATE INDEX customers_customerid_lastname_firstname ON customers(customerid,lastname,firstname);
CREATE INDEX customers_income ON customers(income);
CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
CREATE INDEX customers_state_lastname_firstname ON customers(state,lastname,firstname);
CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
CREATE INDEX orderlines_orderid_orderlineid_quantity ON orderlines(orderid,orderlineid,quantity);
CREATE INDEX orderlines_orderlineid ON orderlines(orderlineid);
CREATE INDEX orderlines_orderlineid_quantity ON orderlines(orderlineid,quantity);
CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
CREATE INDEX orders_customerid ON orders(customerid);
CREATE INDEX orders_orderid_customerid_orderdate ON orders(orderid,customerid,orderdate);
CREATE INDEX orders_orderid ON orders(orderid);
CREATE INDEX products_category ON products(category);
CREATE INDEX products_category_prod_id ON products(category,prod_id);
CREATE INDEX products_price ON products(price);
CREATE INDEX products_using_gist_title_gist_trgm_ops ON products using gist(title gist_trgm_ops);
\c postgres postgres
VACUUM (ANALYZE);
\c ds2 ds2
\qecho --== Query (Q1) ==--
\qecho -- tag::lastname-firstname-customers[]
\! echo "EXPLAIN (ANALYZE 1,COSTS 0,TIMING 1,BUFFERS 0,VERBOSE 0,FORMAT TEXT)" >/tmp/qa
......@@ -32,8 +55,7 @@ SET track_counts TO false;
BEGIN;
\qecho -- tag::lastname-firstname-customers-ci[]
\set ECHO queries
CREATE INDEX customers_lastname_firstname
ON customers(lastname,firstname);
--CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-ci[]
\qecho -- tag::lastname-firstname-customers-explain[]
......@@ -66,8 +88,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-id1000-ci[]
\set ECHO queries
CREATE INDEX customers_customerid_lastname_firstname
ON customers(customerid,lastname,firstname);
--CREATE INDEX customers_customerid_lastname_firstname ON customers(customerid,lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-id1000-ci[]
\qecho -- tag::lastname-firstname-customers-id1000-explain[]
......@@ -100,8 +121,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-idrange-ci[]
\set ECHO queries
CREATE INDEX customers_customerid_lastname_firstname
ON customers(customerid,lastname,firstname);
--CREATE INDEX customers_customerid_lastname_firstname ON customers(customerid,lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-idrange-ci[]
\qecho -- tag::lastname-firstname-customers-idrange-explain[]
......@@ -134,8 +154,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-agerange-ci[]
\set ECHO queries
CREATE INDEX customers_age_lastname_firstname
ON customers(age,lastname,firstname);
--CREATE INDEX customers_age_lastname_firstname ON customers(age,lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-agerange-ci[]
\qecho -- tag::lastname-firstname-customers-agerange-explain[]
......@@ -168,8 +187,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-gtZ-ci[]
\set ECHO queries
CREATE INDEX customers_lastname_firstname
ON customers(lastname,firstname);
--CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-gtZ-ci[]
\qecho -- tag::lastname-firstname-customers-gtZ-explain[]
......@@ -202,8 +220,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-gtN-ci[]
\set ECHO queries
CREATE INDEX customers_lastname_firstname
ON customers(lastname,firstname);
--CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-gtN-ci[]
\qecho -- tag::lastname-firstname-customers-gtN-explain[]
......@@ -236,8 +253,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-orderby-ci[]
\set ECHO queries
CREATE INDEX customers_lastname_firstname
ON customers(lastname,firstname);
--CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-orderby-ci[]
\qecho -- tag::lastname-firstname-customers-orderby-explain[]
......@@ -270,8 +286,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-gtZ-orderby-ci[]
\set ECHO queries
CREATE INDEX customers_lastname_firstname
ON customers(lastname,firstname);
--CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-gtZ-orderby-ci[]
\qecho -- tag::lastname-firstname-customers-gtZ-orderby-explain[]
......@@ -304,8 +319,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::lastname-firstname-customers-stateAR-ci[]
\set ECHO queries
CREATE INDEX customers_state_lastname_firstname
ON customers(state,lastname,firstname);
--CREATE INDEX customers_state_lastname_firstname ON customers(state,lastname,firstname);
\set ECHO none
\qecho -- end::lastname-firstname-customers-stateAR-ci[]
\qecho -- tag::lastname-firstname-customers-stateAR-explain[]
......@@ -338,8 +352,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::title-price-products-subselect-ci[]
\set ECHO queries
CREATE INDEX products_price
ON products(price);
--CREATE INDEX products_price ON products(price);
\set ECHO none
\qecho -- end::title-price-products-subselect-ci[]
\qecho -- tag::title-price-products-subselect-explain[]
......@@ -372,8 +385,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::income_avg-customers-ci[]
\set ECHO queries
CREATE INDEX customers_income
ON customers(income);
--CREATE INDEX customers_income ON customers(income);
\set ECHO none
\qecho -- end::income_avg-customers-ci[]
\qecho -- tag::income_avg-customers-explain[]
......@@ -438,8 +450,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::city-customerid_count-customers-between-groupby-orderby-ci[]
\set ECHO queries
CREATE INDEX customers_city_customerid
ON customers(city,customerid);
--CREATE INDEX customers_city_customerid ON customers(city,customerid);
\set ECHO none
\qecho -- end::city-customerid_count-customers-between-groupby-orderby-ci[]
\qecho -- tag::city-customerid_count-customers-between-groupby-orderby-explain[]
......@@ -472,8 +483,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::city-customerid_count-income_sum-customers-between-groupby-orderby-ci[]
\set ECHO queries
CREATE INDEX customers_city_customerid_income
ON customers(city,customerid,income);
--CREATE INDEX customers_city_customerid_income ON customers(city,customerid,income);
\set ECHO none
\qecho -- end::city-customerid_count-income_sum-customers-between-groupby-orderby-ci[]
\qecho -- tag::city-customerid_count-income_sum-customers-between-groupby-orderby-explain[]
......@@ -506,8 +516,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::orderid-orderlineid-orderlines-limit30-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderid_orderlineid
ON orderlines(orderid,orderlineid);
--CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
\set ECHO none
\qecho -- end::orderid-orderlineid-orderlines-limit30-ci[]
\qecho -- tag::orderid-orderlineid-orderlines-limit30-explain[]
......@@ -540,8 +549,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::star-orderlines-id3-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderid_orderlineid
ON orderlines(orderid,orderlineid);
--CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
\set ECHO none
\qecho -- end::star-orderlines-id3-ci[]
\qecho -- tag::star-orderlines-id3-explain[]
......@@ -574,8 +582,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::star-orderlines-lineid8-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderid_orderlineid
ON orderlines(orderid,orderlineid);
--CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
\set ECHO none
\qecho -- end::star-orderlines-lineid8-ci[]
\qecho -- tag::star-orderlines-lineid8-explain[]
......@@ -608,8 +615,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::star-orderlines-id1-lineid1-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderid_orderlineid
ON orderlines(orderid,orderlineid);
--CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
\set ECHO none
\qecho -- end::star-orderlines-id1-lineid1-ci[]
\qecho -- tag::star-orderlines-id1-lineid1-explain[]
......@@ -642,8 +648,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::orderid-quantity_sum-orderlines-orderid_lt20-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderid_orderlineid
ON orderlines(orderid,orderlineid);
--CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
\set ECHO none
\qecho -- end::orderid-quantity_sum-orderlines-orderid_lt20-ci[]
\qecho -- tag::orderid-quantity_sum-orderlines-orderid_lt20-explain[]
......@@ -676,8 +681,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::count-orderlines-lineid_gt6-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderlineid
ON orderlines(orderlineid);
--CREATE INDEX orderlines_orderlineid ON orderlines(orderlineid);
\set ECHO none
\qecho -- end::count-orderlines-lineid_gt6-ci[]
\qecho -- tag::count-orderlines-lineid_gt6-explain[]
......@@ -710,8 +714,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::count-quantity_sum-orderlines-lineid_gt6-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderlineid_quantity
ON orderlines(orderlineid,quantity);
--CREATE INDEX orderlines_orderlineid_quantity ON orderlines(orderlineid,quantity);
\set ECHO none
\qecho -- end::count-quantity_sum-orderlines-lineid_gt6-ci[]
\qecho -- tag::count-quantity_sum-orderlines-lineid_gt6-explain[]
......@@ -744,8 +747,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::count-quantity_sum-orderlines-lineid_gt10-ci[]
\set ECHO queries
CREATE INDEX orderlines_orderlineid_quantity
ON orderlines(orderlineid,quantity);
--CREATE INDEX orderlines_orderlineid_quantity ON orderlines(orderlineid,quantity);
\set ECHO none
\qecho -- end::count-quantity_sum-orderlines-lineid_gt10-ci[]
\qecho -- tag::count-quantity_sum-orderlines-lineid_gt10-explain[]
......@@ -778,10 +780,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::star-products-titlelike-ci[]
\set ECHO queries
CREATE INDEX products_title
ON products(title);
CREATE INDEX products_using_gist_title_gist_trgm_ops
ON products using gist(title gist_trgm_ops);
--CREATE INDEX products_using_gist_title_gist_trgm_ops ON products using gist(title gist_trgm_ops);
\set ECHO none
\qecho -- end::star-products-titlelike-ci[]
\qecho -- tag::star-products-titlelike-explain[]
......@@ -814,10 +813,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::simple-query-ci[]
\set ECHO queries
CREATE INDEX orders_orderid
ON orders(orderid);
CREATE INDEX orderlines_orderid_orderlineid
ON orderlines(orderid,orderlineid);
--CREATE INDEX orders_orderid ON orders(orderid);
--CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
\set ECHO none
\qecho -- end::simple-query-ci[]
\qecho -- tag::simple-query-explain[]
......@@ -850,10 +847,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::nested-loop-join-ci[]
\set ECHO queries
CREATE INDEX orders_orderid_customerid_orderdate
ON orders(orderid,customerid,orderdate);
CREATE INDEX orderlines_orderid_orderlineid_quantity
ON orderlines(orderid,orderlineid,quantity);
--CREATE INDEX orders_orderid_customerid_orderdate ON orders(orderid,customerid,orderdate);
--CREATE INDEX orderlines_orderid_orderlineid_quantity ON orderlines(orderid,orderlineid,quantity);
\set ECHO none
\qecho -- end::nested-loop-join-ci[]
\qecho -- tag::nested-loop-join-explain[]
......@@ -886,8 +881,7 @@ ROLLBACK;
BEGIN;
\qecho -- tag::non-equi-join-ci[]
\set ECHO queries
CREATE INDEX orders_customerid
ON orders(customerid);
--CREATE INDEX orders_customerid ON orders(customerid);
\set ECHO none
\qecho -- end::non-equi-join-ci[]
\qecho -- tag::non-equi-join-explain[]
......@@ -920,10 +914,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::grouped-join-ci[]
\set ECHO queries
CREATE INDEX products_category
ON products(category);
CREATE INDEX categories_category
ON categories(category);
--CREATE INDEX products_category ON products(category);
--CREATE INDEX categories_category ON categories(category);
\set ECHO none
\qecho -- end::grouped-join-ci[]
\qecho -- tag::grouped-join-explain[]
......@@ -956,10 +948,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::grouped-join-reduced-ci[]
\set ECHO queries
CREATE INDEX products_category_prod_id
ON products(category,prod_id);
CREATE INDEX categories_category_categoryname
ON categories(category,categoryname);
--CREATE INDEX products_category_prod_id ON products(category,prod_id);
--CREATE INDEX categories_category_categoryname ON categories(category,categoryname);
\set ECHO none
\qecho -- end::grouped-join-reduced-ci[]
\qecho -- tag::grouped-join-reduced-explain[]
......@@ -992,10 +982,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::cat11-exists-ci[]
\set ECHO queries
CREATE INDEX products_category
ON products(category);
CREATE INDEX orderlines_prod_id
ON orderlines(prod_id);
--CREATE INDEX products_category ON products(category);
--CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
\set ECHO none
\qecho -- end::cat11-exists-ci[]
\qecho -- tag::cat11-exists-explain[]
......@@ -1028,10 +1016,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::cat11-distinct-ci[]
\set ECHO queries
CREATE INDEX products_category
ON products(category);
CREATE INDEX orderlines_prod_id
ON orderlines(prod_id);
--CREATE INDEX products_category ON products(category);
--CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
\set ECHO none
\qecho -- end::cat11-distinct-ci[]
\qecho -- tag::cat11-distinct-explain[]
......@@ -1064,10 +1050,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::cat11-having-ci[]
\set ECHO queries
CREATE INDEX products_category
ON products(category);
CREATE INDEX orderlines_prod_id
ON orderlines(prod_id);
--CREATE INDEX products_category ON products(category);
--CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
\set ECHO none
\qecho -- end::cat11-having-ci[]
\qecho -- tag::cat11-having-explain[]
......@@ -1100,10 +1084,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::cat11-cte-join-ci[]
\set ECHO queries
CREATE INDEX products_category
ON products(category);
CREATE INDEX orderlines_prod_id
ON orderlines(prod_id);
--CREATE INDEX products_category ON products(category);
--CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
\set ECHO none
\qecho -- end::cat11-cte-join-ci[]
\qecho -- tag::cat11-cte-join-explain[]
......@@ -1136,10 +1118,8 @@ ROLLBACK;
BEGIN;
\qecho -- tag::cat11-cte-subselect-ci[]
\set ECHO queries
CREATE INDEX products_category
ON products(category);
CREATE INDEX orderlines_prod_id
ON orderlines(prod_id);
--CREATE INDEX products_category ON products(category);
--CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
\set ECHO none
\qecho -- end::cat11-cte-subselect-ci[]
\qecho -- tag::cat11-cte-subselect-explain[]
......
......@@ -23,7 +23,7 @@ queries=(
"eo1|count-orderlines-lineid_gt6|(Q20)|SELECT COUNT(*) Anzahl FROM orderlines WHERE orderlineid > 6;|orderlines(orderlineid)|"
"eo1|count-quantity_sum-orderlines-lineid_gt6|(Q21)|SELECT COUNT(*) Anzahl, SUM(quantity) Menge FROM orderlines WHERE orderlineid > 6;|orderlines(orderlineid,quantity)|"
"eo1|count-quantity_sum-orderlines-lineid_gt10|(Q22)|SELECT COUNT(*) Anzahl, SUM(quantity) Menge FROM orderlines WHERE orderlineid > 10;|orderlines(orderlineid,quantity)|"
"eo1|star-products-titlelike|(Q23)|select * from products where title like '%ACADEMY FLY%';|products(title)@products using gist(title gist_trgm_ops)|"
"eo1|star-products-titlelike|(Q23)|select * from products where title like '%ACADEMY FLY%';|products using gist(title gist_trgm_ops)|"
"eo1|simple-query|(Q24) Ein normaler Hash-Join|SELECT o.customerid, o.orderid, o.orderdate, ol.orderlineid, ol.quantity FROM orders o INNER JOIN orderlines ol ON ol.orderid = o.orderid;|orders(orderid)@orderlines(orderid,orderlineid)|"
"eo1|nested-loop-join|(Q25) Nested Loop Join|SELECT o.customerid, o.orderid, o.orderdate, ol.orderlineid, ol.quantity FROM orders o INNER JOIN orderlines ol ON ol.orderid=o.orderid WHERE o.orderid BETWEEN 10 AND 20;|orders(orderid,customerid,orderdate)@orderlines(orderid,orderlineid,quantity)|"
"eo1|non-equi-join|(Q26) Non-Equi Join|SELECT o1.orderid, o2.orderid FROM orders o1 JOIN orders o2 ON o1.orderdate<>o2.orderdate WHERE o1.customerid<100;|orders(customerid)|"
......
......@@ -4,16 +4,26 @@
\c :database :user
CREATE INDEX categories_category_categoryname ON categories(category,categoryname);
CREATE INDEX categories_category ON categories(category);
CREATE INDEX customers_age_lastname_firstname ON customers(age,lastname,firstname);
CREATE INDEX customers_city_customerid_income ON customers(city,customerid,income);
CREATE INDEX customers_city_customerid ON customers(city,customerid);
CREATE INDEX customers_customerid_lastname_firstname ON customers(customerid,lastname,firstname);
CREATE INDEX customers_income ON customers(income);
CREATE INDEX customers_lastname_firstname ON customers(lastname,firstname);
CREATE INDEX customers_state_lastname_firstname ON customers(state,lastname,firstname);
CREATE INDEX orderlines_orderid_orderlineid ON orderlines(orderid,orderlineid);
CREATE INDEX orderlines_orderid_orderlineid_quantity ON orderlines(orderid,orderlineid,quantity);
CREATE INDEX orderlines_orderlineid ON orderlines(orderlineid);
CREATE INDEX orderlines_orderlineid_quantity ON orderlines(orderlineid,quantity);
CREATE INDEX products_price_title ON products(price,title);
CREATE INDEX products_title ON products(title);
CREATE INDEX orderlines_prod_id ON orderlines(prod_id);
CREATE INDEX orders_customerid ON orders(customerid);
CREATE INDEX orders_orderid_customerid_orderdate ON orders(orderid,customerid,orderdate);
CREATE INDEX orders_orderid ON orders(orderid);
CREATE INDEX products_category ON products(category);
CREATE INDEX products_category_prod_id ON products(category,prod_id);
CREATE INDEX products_price ON products(price);
CREATE INDEX products_using_gist_title_gist_trgm_ops ON products using gist(title gist_trgm_ops);
\c :database postgres
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment