#!/usr/bin/sh

echo "\\set ECHO all"
echo "SET max_parallel_workers_maintenance = 8;"

for structure in int intwide text textwide ; do
  for uniqueness in u d ; do
    for order in rand asc desc ; do
     for maintenance_work_mem in 1MB 64MB 256MB 512MB ; do
        echo "SET maintenance_work_mem = '$maintenance_work_mem';"

        # create one throwaway index without measuring so that none of the following test runs has unfairly cold caches
        echo "\\timing off"
        echo "DROP INDEX IF EXISTS test_idx;"
        echo "CREATE INDEX test_idx ON test_${structure}_${uniqueness}_${order}(key);"
        echo "\\timing on"

        for parallel_workers in 0 1 2 3 4 5 6 7 8 ; do
          echo "DROP INDEX IF EXISTS test_idx;"
          echo "CREATE INDEX test_idx ON test_${structure}_${uniqueness}_${order}(key) WITH (parallel_workers = $parallel_workers);"
          if [ "$uniqueness" == "u" ] ; then
            echo "DROP INDEX IF EXISTS test_idx;"
            echo "CREATE UNIQUE INDEX test_idx ON test_${structure}_${uniqueness}_${order}(key) WITH (parallel_workers = $parallel_workers);"
          fi
        done
      done
    done
  done
done

echo "DROP INDEX IF EXISTS test_idx;"
