Commit 0dd3c7ca authored by Marcel Huber's avatar Marcel Huber
Browse files

ColumnStore: adjusted script to create pg sql statements

parent 872b00d0
......@@ -10,6 +10,8 @@ db_user=${2:-$db_name}
eo0=""
# shellcheck disable=SC2034
eo1="EXPLAIN (ANALYZE 1,COSTS 0,TIMING 1,BUFFERS 0,VERBOSE 0,FORMAT TEXT)"
# shellcheck disable=SC2034
eo2=""
# shellcheck source=./Queries_common.sh
. $_EX_DIR/Queries_common.sh
......@@ -18,6 +20,25 @@ 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
......@@ -36,26 +57,53 @@ SET track_counts TO false;
-- columns is in effect when using wrapped mode
\pset columns $colwidth
\c $db_name $db_user
$(sed -n '/CREATE INDEX/ p' $_EX_DIR/ds2_indexes.sql)
\c postgres postgres
VACUUM (ANALYZE);
\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 \$"$(cut -d'|' -f1 <<<"$q")")";
aufgabe="$(cut -d'|' -f2 <<<"$q")";
aufgabe_desc="$(cut -d'|' -f3 <<<"$q")";
query="$(cut -d'|' -f4 <<<"$q")";
_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[]"
......@@ -66,6 +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
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