Skip to content

Instantly share code, notes, and snippets.

@dchimeno
Created June 29, 2021 10:06
Show Gist options
  • Save dchimeno/0f2d104e86edb3ddf3a302bfafd2fb17 to your computer and use it in GitHub Desktop.
Save dchimeno/0f2d104e86edb3ddf3a302bfafd2fb17 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
QUERIES_FILE="bench_queries-uk.sql"
TABLE=$1
TRIES=3
cat "$QUERIES_FILE" | sed "s/{table}/${TABLE}/g" | while read query; do
if [ $query != "--*" ]
then
echo "query"
sync
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
echo -n "["
for i in $(seq 1 $TRIES); do
RES=$(clickhouse-client --time --format=Null --query="$query" 2>&1)
[[ "$?" == "0" ]] && echo -n "${RES}" || echo -n "null"
[[ "$i" != $TRIES ]] && echo -n ", "
done
echo -n "],"
else
echo "sin entrar"
echo $query
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment