Queries_MonetDB.sh 1.74 KB
Newer Older
Marcel Huber's avatar
Marcel Huber committed
1
#!/bin/bash
2

Marcel Huber's avatar
Marcel Huber committed
3
4
_MY_DIR="$(cd "$(dirname "${0:-.}")" && pwd)"
_EX_DIR="$(realpath --relative-to=. "$_MY_DIR")"
5
6
test -z "$_EX_DIR" && _EX_DIR=.

Marcel Huber's avatar
Marcel Huber committed
7
8
# shellcheck source=./Queries_common.sh
. $_EX_DIR/Queries_common.sh
9
10
# disable globbing for star queries (*)
set -f
11
cat <<EOF
12
13
14
15
16
17
18
19
-- Source this file from within mclient using \< Queries_MonetDB.sql
-- If "\f trash" does not work (usually when using content from stdin), set
-- "--interactive" option when starting mclient
-- disable auto commit
\a
-- initially disable performance timing (trace command)
\t none
set schema ds2;
20
21
-- FIXME: set correct permissions to select from sys.tracelog as ds2 user
set role sysadmin;
22
--
23
$(for q in "${queries[@]}"; do
Marcel Huber's avatar
Marcel Huber committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
	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 "\f raw"
	echo "plan $query"
	echo "\f tab"
	echo "select '-- end::${aufgabe}-plan[]';"
Marcel Huber's avatar
Marcel Huber committed
39
40
41
	echo "\f trash"
	echo "$query"
	echo "\f tab"
Marcel Huber's avatar
Marcel Huber committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
	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 "\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}[]';"
59
60
done)
EOF