Commit acc2ea05 authored by Marcel Huber's avatar Marcel Huber
Browse files

Merge branch 'release_20.10.0'

parents 45ffeebf c3f3088a
Pipeline #42012 passed with stages
in 5 minutes and 40 seconds
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
#!/bin/bash
_MY_DIR="$(cd $(dirname ${0:-.}) && pwd)"
_EX_DIR="$(realpath --relative-to=. $_MY_DIR)"
_MY_DIR="$(cd "$(dirname "${0:-.}")" && pwd)"
_EX_DIR="$(realpath --relative-to=. "$_MY_DIR")"
test -z "$_EX_DIR" && _EX_DIR=.
eo0=""
eo1=""
source $_EX_DIR/Queries_common.sh
# shellcheck source=./Queries_common.sh
. $_EX_DIR/Queries_common.sh
# disable globbing for star queries (*)
set -f
cat <<EOF
......@@ -23,38 +21,40 @@ set schema ds2;
set role sysadmin;
--
$(for q in "${queries[@]}"; do
explainopts="$(eval echo $(echo \"\$$(cut -d'|' -f1 <<<$q)\"))";
aufgabe="$(cut -d'|' -f2 <<<$q)";
aufgabe_desc="$(cut -d'|' -f3 <<<$q)";
query="$(cut -d'|' -f4 <<<$q)";
query_escaped="$(echo -n $query | sed 's/\x27/\\\x27/g')";
baseindex="";
indexcond="";
aufgabe="$(cut -d'|' -f2 <<<"$q")";
aufgabe_desc="$(cut -d'|' -f3 <<<"$q")";
query="$(cut -d'|' -f4 <<<"$q")";
query_escaped="$(echo -n "$query" | sed 's/\x27/\\\x27/g')";
echo "\f tab"
echo "select '--== Query "$aufgabe_desc" ==--';"
echo "select '-- tag::"${aufgabe}"[]';"
echo "select '-- tag::"${aufgabe}"-query[]';"
echo "select '"$query_escaped"';"
echo "select '-- end::"${aufgabe}"-query[]';"
echo "select '-- tag::"${aufgabe}"-plan[]';"
echo "select '--== Query $aufgabe_desc ==--';"
echo "select '-- tag::${aufgabe}[]';"
echo "select '-- tag::${aufgabe}-query[]';"
echo "select '$query_escaped';"
echo "select '-- end::${aufgabe}-query[]';"
echo "select '-- tag::${aufgabe}-plan[]';"
echo "\f raw"
echo "plan $query"
echo "\f tab"
echo "select '-- end::"${aufgabe}"-plan[]';"
echo "select '-- tag::"${aufgabe}"-timing[]';"
echo "select '-- end::${aufgabe}-plan[]';"
echo "\f trash"
echo "$query"
echo "\f tab"
echo "select '-- tag::${aufgabe}-timing[]';"
echo "\f trash"
# shellcheck disable=SC2028
echo "\t performance"
echo "$query"
# shellcheck disable=SC2028
echo "\t none"
echo "\f tab"
echo "select '-- end::"${aufgabe}"-timing[]';"
echo "select '-- tag::"${aufgabe}"-trace[]';"
echo "select '-- end::${aufgabe}-timing[]';"
echo "select '-- tag::${aufgabe}-trace[]';"
echo "\f rowcount"
echo "trace $query"
echo "\f csv+;"
echo "select ticks as usec, stmt from sys.tracelog;"
echo "\f tab"
echo "select '-- end::"${aufgabe}"-trace[]';"
echo "select '-- end::"${aufgabe}"[]';"
echo "select '-- end::${aufgabe}-trace[]';"
echo "select '-- end::${aufgabe}[]';"
done)
EOF
This diff is collapsed.
#!/bin/sh
#!/bin/bash
_MY_DIR="$(cd $(dirname ${0:-.}) && pwd)"
_EX_DIR="$(realpath --relative-to=. $_MY_DIR)"
_MY_DIR="$(cd "$(dirname "${0:-.}")" && pwd)"
_EX_DIR="$(realpath --relative-to=. "$_MY_DIR")"
test -z "$_EX_DIR" && _EX_DIR=.
db_name=${1:-ds2}
db_user=${2:-$db_name}
# shellcheck disable=SC2034
eo0=""
# shellcheck disable=SC2034
eo1="EXPLAIN (ANALYZE 1,COSTS 0,TIMING 1,BUFFERS 0,VERBOSE 0,FORMAT TEXT)"
# shellcheck disable=SC2034
eo2=""
source $_EX_DIR/Queries_common.sh
# shellcheck source=./Queries_common.sh
. $_EX_DIR/Queries_common.sh
echostr=""
echostr="\qecho "
format_text="aligned" # or wrapped
colwidth=0
indexatonce=1
query_with_disabled_hashjoin() {
true
}
create_indexes() {
_index="$1"
test -z "$_index" && return
_prefix="${2:-}"
_nl="${3:-$(printf "\n ")}"
oldIFS=$IFS
IFS="@"
for ix in $_index; do
IFS=$oldIFS
_indexname="$(tr '(, ' '_' <<<"$ix" | tr -d ')')";
test -n "$_indexname" && printf "%sCREATE INDEX %s%sON %s;\n" "$_prefix" "$_indexname" "$_nl" "$ix"
done;
}
cat <<EOF
-- anzeigen der aktuellen Einstellungen
......@@ -34,25 +57,53 @@ SET track_counts TO false;
-- columns is in effect when using wrapped mode
\pset columns $colwidth
\c $db_name $db_user
$(test "$indexatonce" -ne 0 && {
for q in "${queries[@]}"; do
_colidx=5;
baseindex="$(cut -d'|' -f$_colidx <<<"$q")";
create_indexes "$baseindex" "" " "
done | sort | uniq
echo "\c postgres postgres"
echo "VACUUM (ANALYZE);"
echo "\c $db_name $db_user"
})
$(for q in "${queries[@]}"; do
explainopts="$(eval echo $(echo \"\$$(cut -d'|' -f1 <<<$q)\"))";
aufgabe="$(cut -d'|' -f2 <<<$q)";
aufgabe_desc="$(cut -d'|' -f3 <<<$q)";
query="$(cut -d'|' -f4 <<<$q)";
baseindex="";
indexcond="";
_colidx=1;
explainopts="$(eval "echo \$$(cut -d'|' -f$_colidx <<<"$q")")"; _colidx=$((_colidx+1));
aufgabe="$(cut -d'|' -f$_colidx <<<"$q")"; _colidx=$((_colidx+1));
aufgabe_desc="$(cut -d'|' -f$_colidx <<<"$q")"; _colidx=$((_colidx+1));
query="$(cut -d'|' -f$_colidx <<<"$q")"; _colidx=$((_colidx+1));
baseindex="$(cut -d'|' -f$_colidx <<<"$q")"; _colidx=$((_colidx+1));
indexcond="$(cut -d'|' -f$_colidx <<<"$q")"; _colidx=$((_colidx+1));
echo "${echostr}--== Query $aufgabe_desc ==--"
echo "${echostr}-- tag::${aufgabe}[]"
echo "\! echo \"$explainopts\" >/tmp/qa"
echo "${echostr}-- tag::${aufgabe}-eo[]"
echo "\! cat /tmp/qa"
echo "${echostr}-- end::${aufgabe}-eo[]"
echo "\! echo \"$query\" | pg_format -f1 -s2 -u2 | tee -a /tmp/qa >/tmp/q"
echo "\! echo \"$query\" >/tmp/qx"
echo "\! pg_format -f1 -s2 -u2 -U2 </tmp/qx | tee -a /tmp/qa >/tmp/q"
echo "${echostr}-- tag::${aufgabe}-query-ea[]"
echo "\! cat /tmp/qa"
echo "${echostr}-- end::${aufgabe}-query-ea[]"
echo "${echostr}-- tag::${aufgabe}-query[]"
echo "\! cat /tmp/q"
echo "${echostr}-- end::${aufgabe}-query[]"
test "x$aufgabe_desc" = "xsimple-exec" && {
echo "\i /tmp/q";
echo "${echostr}-- end::${aufgabe}[]"
continue;
}
echo "BEGIN;"
echo "${echostr}-- tag::${aufgabe}-ci[]"
echo "\set ECHO queries"
if [ "$indexatonce" -eq 0 ]; then
create_indexes "$baseindex" "" " ";
else
create_indexes "$baseindex" "--" " ";
fi
echo "\set ECHO none"
echo "${echostr}-- end::${aufgabe}-ci[]"
echo "${echostr}-- tag::${aufgabe}-explain[]"
echo "\pset format asciidoc"
echo "${echostr}-- tag::${aufgabe}-explain-adoc[]"
......@@ -63,7 +114,31 @@ $(for q in "${queries[@]}"; do
echo "\i /tmp/qa"
echo "${echostr}-- end::${aufgabe}-explain-text[]"
echo "${echostr}-- end::${aufgabe}-explain[]"
query_with_disabled_hashjoin "${aufgabe}-nhj"
echo "ROLLBACK;"
test -n "$indexcond" && {
echo "BEGIN;"
echo "${echostr}-- tag::${aufgabe}-i[]"
echo "${echostr}-- tag::${aufgabe}-i-ci[]"
echo "\set ECHO queries"
create_indexes "$indexcond"
echo "\set ECHO none"
echo "${echostr}-- end::${aufgabe}-i-ci[]"
echo "${echostr}-- tag::${aufgabe}-i-explain[]"
echo "\pset format asciidoc"
echo "${echostr}-- tag::${aufgabe}-i-explain-adoc[]"
echo "\i /tmp/qa"
echo "${echostr}-- end::${aufgabe}-i-explain-adoc[]"
echo "\pset format ${format_text}"
echo "${echostr}-- tag::${aufgabe}-i-explain-text[]"
echo "\i /tmp/qa"
echo "${echostr}-- end::${aufgabe}-i-explain-text[]"
echo "${echostr}-- end::${aufgabe}-i-explain[]"
query_with_disabled_hashjoin "${aufgabe}-i-nhj"
echo "${echostr}-- end::${aufgabe}-i[]"
echo "ROLLBACK;"
}
echo "\! rm -f /tmp/q /tmp/qa /tmp/qx"
echo "${echostr}-- end::${aufgabe}[]"
done)
EOF
This diff is collapsed.
# shellcheck shell=bash
# shellcheck disable=SC2034
queries=(
"eo1|lastname-firstname-customers|(Q1)|select lastname, firstname from customers;||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-id1000|(Q2)|select lastname, firstname from customers where customerid=1000;||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-idrange|(Q3)|select lastname, firstname from customers where customerid between 1000 and 1100;||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-agerange|(Q4)|select lastname, firstname from customers where age between 20 and 30;||customers(age,lastname,firstname)"
"eo1|lastname-firstname-customers-gtZ|(Q5)|select lastname, firstname from customers where lastname > 'Z';||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-gtN|(Q6)|select firstname from customers where lastname > 'N';||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-orderby|(Q7)|select lastname, firstname from customers order by lastname, firstname;||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-gtZ-orderby|(Q8)|select lastname, firstname from customers where lastname > 'Z' order by lastname, firstname;||customers(lastname,firstname)"
"eo1|lastname-firstname-customers-stateAR|(Q9)|select lastname, firstname from customers where state='AR';||customers(state,lastname,firstname)"
"eo1|title-price-products-subselect|(Q10)|select title, price from products where price=(select max(price) from products);||products(price,title)"
"eo1|income_avg-customers|(Q11)|select avg(income) from customers;||customers(income)"
"eo1|lastname-firstname-customers|(Q1)|select lastname, firstname from customers;|customers(lastname,firstname)|"
"eo1|lastname-firstname-customers-id1000|(Q2)|select lastname, firstname from customers where customerid=1000;|customers(customerid,lastname,firstname)|"
"eo1|lastname-firstname-customers-idrange|(Q3)|select lastname, firstname from customers where customerid between 1000 and 1100;|customers(customerid,lastname,firstname)|"
"eo1|lastname-firstname-customers-agerange|(Q4)|select lastname, firstname from customers where age between 20 and 30;|customers(age,lastname,firstname)|"
"eo1|lastname-firstname-customers-gtZ|(Q5)|select lastname, firstname from customers where lastname > 'Z';|customers(lastname,firstname)|"
"eo1|lastname-firstname-customers-gtN|(Q6)|select firstname from customers where lastname > 'N';|customers(lastname,firstname)|"
"eo1|lastname-firstname-customers-orderby|(Q7)|select lastname, firstname from customers order by lastname, firstname;|customers(lastname,firstname)|"
"eo1|lastname-firstname-customers-gtZ-orderby|(Q8)|select lastname, firstname from customers where lastname > 'Z' order by lastname, firstname;|customers(lastname,firstname)|"
"eo1|lastname-firstname-customers-stateAR|(Q9)|select lastname, firstname from customers where state='AR';|customers(state,lastname,firstname)|"
"eo1|title-price-products-subselect|(Q10)|select title, price from products where price=(select max(price) from products);|products(price)|"
"eo1|income_avg-customers|(Q11)|select avg(income) from customers;|customers(income)|"
"eo1|customerid_max-customers|(Q12)|select max(customerid) from customers;||"
"eo1|city-customerid_count-customers-between-groupby-orderby|(Q13)|select city, count(customerid) from customers where city between 'B' and 'E' group by city order by city;||customers(city,customerid)"
"eo1|city-customerid_count-income_sum-customers-between-groupby-orderby|(Q14)|select city, count(customerid), sum(income) from customers where city between 'B' and 'E' group by city order by city;||customers(city,customerid,income)"
"eo1|city-customerid_count-customers-between-groupby-orderby|(Q13)|select city, count(customerid) from customers where city between 'B' and 'E' group by city order by city;|customers(city,customerid)|"
"eo1|city-customerid_count-income_sum-customers-between-groupby-orderby|(Q14)|select city, count(customerid), sum(income) from customers where city between 'B' and 'E' group by city order by city;|customers(city,customerid,income)|"
"eo1|orderid-orderlineid-orderlines-limit30|(Q15)|SELECT orderid, orderlineid FROM orderlines LIMIT 30;|orderlines(orderid,orderlineid)|"
"eo1|star-orderlines-id3|(Q16)|SELECT * FROM orderlines WHERE orderid=3;|orderlines(orderid,orderlineid)|"
"eo1|star-orderlines-lineid8|(Q17)|SELECT * FROM orderlines WHERE orderlineid=8;|orderlines(orderid,orderlineid)|"
"eo1|star-orderlines-id1-lineid1|(Q18)|SELECT * FROM orderlines WHERE orderlineid=1 AND orderid=1;|orderlines(orderid,orderlineid)|"
"eo1|orderid-quantity_sum-orderlines-orderid_lt20|(Q19)|SELECT orderid, SUM(quantity) quantity FROM orderlines WHERE orderid < 20 GROUP BY orderid;|orderlines(orderid,orderlineid)|"
"eo1|count-orderlines-lineid_gt6|(Q20)|SELECT COUNT(*) Anzahl FROM orderlines WHERE orderlineid > 6;|orderlines(orderid,orderlineid)|"
"eo1|count-quantity_sum-orderlines-lineid_gt6|(Q21)|SELECT COUNT(*) Anzahl, SUM(quantity) Menge FROM orderlines WHERE orderlineid > 6;|orderlines(orderid,orderlineid)|orderlines(orderlineid,quantity)"
"eo1|count-quantity_sum-orderlines-lineid_gt10|(Q22)|SELECT COUNT(*) Anzahl, SUM(quantity) Menge FROM orderlines WHERE orderlineid > 10;|orderlines(orderid,orderlineid)|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|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,customerid,orderdate)@orderlines(orderid,orderlineid,quantity)"
"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)@orders(customerid,orderdate)"
"eo1|grouped-join|(Q27)|SELECT cat.categoryname, count(prod.prod_id) anzahl FROM products prod INNER JOIN categories cat ON prod.category=cat.category GROUP BY cat.categoryname ORDER BY cat.categoryname;||products(category)"
"eo1|grouped-join-reduced|(Q28) Eingeschränkt|SELECT cat.categoryname, count(prod.prod_id) anzahl FROM products prod INNER JOIN categories cat ON prod.category=cat.category WHERE cat.category = 6 GROUP BY cat.categoryname ORDER BY cat.categoryname;||"
"eo1|cat11-exists|(Q29) Ein Produkt der Kategorie 11 mit EXISTS|SELECT * FROM orders o WHERE EXISTS ( SELECT * FROM orderlines ol inner join products p on ol.prod_id=p.prod_id WHERE ol.orderId=o.orderid AND P.category=11);||products(category)@orderlines(prod_id)"
"eo1|cat11-distinct|(Q30) Ein Produkt der Kategorie 11 mit DISTINCT|SELECT DISTINCT o.* FROM orders o inner join orderlines ol on ol.orderId=o.orderid inner join products p on ol.prod_id=p.prod_id WHERE P.category=11;||products(category)@orderlines(prod_id)"
"eo1|cat11-having|(Q31) Ein Produkt der Kategorie 11 mit HAVING|SELECT o.orderid,o.orderdate,o.customerid,o.netamount,o.tax,o.totalamount FROM orders o inner join orderlines ol on ol.orderId=o.orderid inner join products p on ol.prod_id=p.prod_id GROUP BY p.category,o.orderid,o.orderdate,o.customerid,o.netamount,o.tax,o.totalamount HAVING p.category=11;||products(category)@orderlines(prod_id)"
"eo1|cat11-cte-join|(Q32)|with orderlines_to_products_eleven as (select * from products p inner join orderlines ol on ol.prod_id=p.prod_id where p.category=11) select * from orders o inner join orderlines_to_products_eleven ope on o.orderid=ope.orderid;||products(category)@orderlines(prod_id)"
"eo1|cat11-cte-subselect|(Q33)|with cat_eleven_products as ( select * from products where category=11 ), orderlines_to_products_eleven as ( select * from orderlines ol, cat_eleven_products cep where ol.prod_id=cep.prod_id ) select * from orders o inner join orderlines_to_products_eleven ope on o.orderid=ope.orderid;||products(category)@orderlines(prod_id)"
"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 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)|"
"eo1|grouped-join|(Q27)|SELECT cat.categoryname, count(prod.prod_id) anzahl FROM products prod INNER JOIN categories cat ON prod.category=cat.category GROUP BY cat.categoryname ORDER BY cat.categoryname;|products(category)@categories(category)|"
"eo1|grouped-join-reduced|(Q28) Eingeschränkt|SELECT cat.categoryname, count(prod.prod_id) anzahl FROM products prod INNER JOIN categories cat ON prod.category=cat.category WHERE cat.category = 6 GROUP BY cat.categoryname ORDER BY cat.categoryname;|products(category,prod_id)@categories(category,categoryname)|"
"eo1|cat11-exists|(Q29) Ein Produkt der Kategorie 11 mit EXISTS|SELECT * FROM orders o WHERE EXISTS ( SELECT * FROM orderlines ol inner join products p on ol.prod_id=p.prod_id WHERE ol.orderid=o.orderid AND P.category=11);|products(category)@orderlines(prod_id)|"
"eo1|cat11-distinct|(Q30) Ein Produkt der Kategorie 11 mit DISTINCT|SELECT DISTINCT o.* FROM orders o inner join orderlines ol on ol.orderid=o.orderid inner join products p on ol.prod_id=p.prod_id WHERE P.category=11;|products(category)@orderlines(prod_id)|"
"eo1|cat11-having|(Q31) Ein Produkt der Kategorie 11 mit HAVING|SELECT o.orderid,o.orderdate,o.customerid,o.netamount,o.tax,o.totalamount FROM orders o inner join orderlines ol on ol.orderid=o.orderid inner join products p on ol.prod_id=p.prod_id GROUP BY p.category,o.orderid,o.orderdate,o.customerid,o.netamount,o.tax,o.totalamount HAVING p.category=11;|products(category)@orderlines(prod_id)|"
"eo1|cat11-cte-join|(Q32)|with orderlines_to_products_eleven as (select * from products p inner join orderlines ol on ol.prod_id=p.prod_id where p.category=11) select * from orders o inner join orderlines_to_products_eleven ope on o.orderid=ope.orderid;|products(category)@orderlines(prod_id)|"
"eo1|cat11-cte-subselect|(Q33)|with cat_eleven_products as ( select * from products where category=11 ), orderlines_to_products_eleven as ( select * from orderlines ol, cat_eleven_products cep where ol.prod_id=cep.prod_id ) select * from orders o inner join orderlines_to_products_eleven ope on o.orderid=ope.orderid;|products(category)@orderlines(prod_id)|"
"eo1|customerid_avg-cust_hist|(Q34)|select avg(customerid) from cust_hist;||"
)
This diff is collapsed.
This diff is collapsed.
......@@ -4,17 +4,28 @@
\c :database :user
create index customers_age on customers(age,lastname,firstname);
create index customers_city on customers(city);
create index customers_income on customers(income);
create index customers_lastname_firstname on customers(lastname,firstname);
create index customers_state on customers(state);
create index orderlines_orderid_orderlineid on orderlines(orderid,orderlineid);
create index orderlines_orderlineid_quantity on orderlines(orderlineid,quantity);
create index products_price on products(price);
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 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 :database postgres
vacuum (analyze);
VACUUM (ANALYZE);
......@@ -222,6 +222,7 @@ for dbtype in MonetDB PostgreSQL; do
_queries_generate_script="${_EX_DIR}/${docname}_${dbtype}.sh"
test -f "$_queries_generate_script" || continue
_queries_file=${_EX_DIR}/${docname}_${dbtype}.sql
# _RM_LIST="$_RM_LIST:$_queries_file"
_test_date="$(date +%Y%m%d%H%M%S)"
_logbase="${_EX_DIR}/${_EX_NAME}.${dbtype}"
_logfile="${_logbase}.${_test_date}.log"
......
......@@ -16,12 +16,12 @@ ALTER TABLE ds2.products
ADD CONSTRAINT products_pkey PRIMARY KEY (prod_id);
ALTER TABLE ds2.cust_hist
ADD CONSTRAINT fk_cust_hist_customerid FOREIGN KEY (customerid) REFERENCES customers(customerid) ON DELETE CASCADE;
ADD CONSTRAINT fk_cust_hist_customerid FOREIGN KEY (customerid) REFERENCES customers (customerid) ON DELETE CASCADE;
ALTER TABLE ds2.orders
ADD CONSTRAINT fk_customerid FOREIGN KEY (customerid) REFERENCES customers(customerid) ON DELETE SET NULL;
ADD CONSTRAINT fk_customerid FOREIGN KEY (customerid) REFERENCES customers (customerid) ON DELETE SET NULL;
ALTER TABLE ds2.orderlines
ADD CONSTRAINT fk_orderid FOREIGN KEY (orderid) REFERENCES orders(orderid) ON DELETE CASCADE;
ADD CONSTRAINT fk_orderid FOREIGN KEY (orderid) REFERENCES orders (orderid) ON DELETE CASCADE;
COMMIT;
SET SCHEMA ds2;
-- drop tables in reversed order
DROP TABLE ds2.reorder CASCADE;
DROP TABLE ds2.products CASCADE;
DROP TABLE ds2.orders CASCADE;
DROP TABLE ds2.orderlines CASCADE;
DROP TABLE ds2.inventory CASCADE;
DROP TABLE ds2.customers CASCADE;
DROP TABLE ds2.cust_hist CASCADE;
DROP TABLE ds2.categories CASCADE;
-- set schema of ds2 user to default
ALTER USER "ds2" SET SCHEMA "sys";
SET SCHEMA sys;
DROP SCHEMA ds2;
DROP USER ds2;
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