create_data.sh
application/x-shellscript
Filename: create_data.sh
Type: application/x-shellscript
Part: 0
#!/bin/sh
# tweak maintenance_work_mem as appropriate
for power in 3 4 5 6 7; # 6: 1M 7: 10M
# for power in 8 ; # 6: 1M 7: 10M
do
table=azjunk${power}
index=${table}_trgm_re_idx
echo "-- generating table $table with index $index";
time perl -E'
sub ss{ join"",@_[ map{rand @_} 1 .. shift ] };
say(ss(80,"a".."g"," ","h".."m"," ","n".."s"," ","t".."z"))
for 1 .. 1e'"${power};" \
| psql -aqXc "
drop table if exists $table;
create table $table(txt text); copy $table from stdin;
set session maintenance_work_mem='1500MB';
create index $index on $table using gin (txt gin_trgm_ops);
analyze $table;" ;
echo "select current_setting('server_version') as version,'$table' as table
,pg_size_pretty(pg_relation_size('public.$table')) as data
,pg_size_pretty(pg_relation_size('public.$index')) as idx
,(select reltuples+0 from pg_class where relname='$table')as rowcount;"|psql;
done