|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# ############################################################################## |
| 4 | +# |
| 5 | +# Pass each JOB query over the DBMS instance. Use $1 to specify a number of |
| 6 | +# iterations, if needed. |
| 7 | +# |
| 8 | +# Results: |
| 9 | +# - explains.txt - explain of each query |
| 10 | +# - job_onepass_aqo_stat.dat - short report on execution time |
| 11 | +# - knowledge_base.dump - dump of the AQO knowledge base |
| 12 | +# |
| 13 | +# ############################################################################## |
| 14 | + |
| 15 | +echo "The Join Order Benchmark 1Pass" |
| 16 | +echo -e "Query Number\tITER\tQuery Name\tExecution Time, ms" > report.txt |
| 17 | +echo -e "Clear a file with explains" > explains.txt |
| 18 | + |
| 19 | +if [ $# -eq 0 ] |
| 20 | +then |
| 21 | + ITERS=1 |
| 22 | +else |
| 23 | + ITERS=$1 |
| 24 | +fi |
| 25 | + |
| 26 | +echo "Execute JOB with the $ITERS iterations" |
| 27 | + |
| 28 | +filenum=1 |
| 29 | +for file in $JOB_DIR/queries/*.sql |
| 30 | +do |
| 31 | + # Get filename |
| 32 | + short_file=$(basename "$file") |
| 33 | + |
| 34 | + echo -n "EXPLAIN (ANALYZE, VERBOSE, FORMAT JSON) " > test.sql |
| 35 | + cat $file >> test.sql |
| 36 | + |
| 37 | + for (( i=1; i<=$ITERS; i++ )) |
| 38 | + do |
| 39 | + result=$(psql -f test.sql) |
| 40 | + echo -e $result >> explains.txt |
| 41 | + exec_time=$(echo $result | sed -n 's/.*"Execution Time": \([0-9]*\.[0-9]*\).*/\1/p') |
| 42 | + echo -e "$filenum\t$short_file\t$i\t$exec_time" >> report.txt |
| 43 | + echo -e "$filenum\t$i\t$short_file\t$exec_time" |
| 44 | + done |
| 45 | +filenum=$((filenum+1)) |
| 46 | +done |
| 47 | + |
| 48 | +# Show total optimizer error in the test |
| 49 | +psql -c "SELECT sum(error) AS total_error FROM aqo_cardinality_error(false)" |
| 50 | +psql -c "SELECT sum(error) AS total_error_aqo FROM aqo_cardinality_error(true)" |
| 51 | + |
| 52 | +# Show error delta (Negative result is a signal of possible issue) |
| 53 | +psql -c " |
| 54 | +SELECT id, (o.error - c.error) AS errdelta |
| 55 | + FROM aqo_cardinality_error(true) c JOIN aqo_cardinality_error(false) o |
| 56 | + USING (id) |
| 57 | +" |
| 58 | + |
0 commit comments