$ cat ./generate_words.pl #!/bin/env perl use strict; my $numofwords= 50_000_000; for (my $i=0; $i<$numofwords; ++$i) { my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(! @ $ % ^ & *) ); my $rin = join("", @chars[ map { rand @chars } ( 1 .. 5 ) ] ) ; print $rin, "\n"; } #### $ time perl ./generate_words.pl > words.txt; real 7m54.686s $ time ( < words.txt psql -d test -c " drop table if exists words; create table words (word text, id serial); copy words(word) from stdin csv; " ) real 1m16.223s