#!/bin/sh

psql postgres <<EOF
DROP TABLE IF EXISTS mjtest;

CREATE TABLE mjtest (key int PRIMARY KEY);

INSERT INTO mjtest SELECT * FROM generate_series(1,300000) AS bar;

VACUUM ANALYZE mjtest;

EOF

# warm-up
psql postgres -c "SELECT * FROM mjtest a, mjtest b WHERE a.key = b.key ORDER BY a.key" > /dev/null
psql postgres -c "SELECT * FROM mjtest a, mjtest b WHERE a.key = b.key ORDER BY a.key" > /dev/null

time psql postgres -c "SELECT * FROM mjtest a, mjtest b WHERE a.key = b.key ORDER BY a.key" > /dev/null