2016-12-21 20:04:27 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-03-30 11:27:22 +00:00
|
|
|
|
|
|
|
QUERIES_FILE="queries.sql"
|
|
|
|
TABLE=$1
|
|
|
|
TRIES=3
|
|
|
|
|
|
|
|
cat "$QUERIES_FILE" | sed "s/{table}/${TABLE}/g" | while read query; do
|
2017-04-05 11:52:23 +00:00
|
|
|
sync
|
|
|
|
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
|
2015-03-30 11:27:22 +00:00
|
|
|
|
2017-04-05 11:52:23 +00:00
|
|
|
echo -n "["
|
|
|
|
for i in $(seq 1 $TRIES); do
|
2015-03-30 11:27:22 +00:00
|
|
|
|
2017-04-05 11:52:23 +00:00
|
|
|
RES=$((echo '\timing'; echo "$query") |
|
|
|
|
/opt/vertica/bin/vsql -U dbadmin |
|
|
|
|
grep -oP 'All rows formatted: [^ ]+ ms' |
|
|
|
|
ssed -R -e 's/^All rows formatted: ([\d,]+) ms$/\1/' |
|
|
|
|
tr ',' '.')
|
2015-03-30 11:27:22 +00:00
|
|
|
|
2017-04-05 11:52:23 +00:00
|
|
|
[[ "$?" == "0" ]] && echo -n "$(perl -e "print ${RES} / 1000")" || echo -n "null"
|
|
|
|
[[ "$i" != $TRIES ]] && echo -n ", "
|
|
|
|
done
|
|
|
|
echo "],"
|
2015-03-30 11:27:22 +00:00
|
|
|
done
|