casanova_test.sh
application/x-shellscript
#!/bin/sh
t=t1
table_count=$( echo "select count(*) from information_schema.tables
where table_schema = 'public' and table_name = '$t'" | psql -qtAX );
if [[ 1 -eq 0 || $table_count -eq 0 ]];
then
echo "
drop table if exists $t;
create table $t (i int);
create index ${t}_i_idx on $t using minmax(i);
insert into $t select generate_series(1, 25000000);
analyze t1;
" | psql -qa
fi
(
echo "set enable_bitmapscan=1; explain analyze select i from $t where i between 10000000 and 10001000;";
echo "set enable_bitmapscan=0; explain analyze select i from $t where i between 10000000 and 10001000;";
) | psql -qa