8 use Time::HiRes qw(gettimeofday tv_interval);
10 my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
12 plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
13 unless ($dsn && $dbuser);
17 sub create_test_schema {
19 $schema->storage->dbh_do(
22 local $dbh->{Warn} = 0;
26 artistid serial NOT NULL PRIMARY KEY,
31 ],{ RaiseError => 0, PrintError => 0 });
35 sub drop_test_schema {
37 $schema->storage->dbh_do(
40 local $dbh->{Warn} = 0;
41 eval { $dbh->do('DROP TABLE IF EXISTS artist') };
42 eval { $dbh->do('DROP SEQUENCE public.artist_artistid_seq') };
46 # copied from 100populate.t
48 my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
49 drop_test_schema($schema);create_test_schema($schema);
52 return unless $schema;
53 drop_test_schema($schema);
56 my $start_id = 'populateXaaaaaa';
60 $schema->populate('Artist', [ [ qw/artistid name/ ], map { [ ($_ + $offset) => $start_id++ ] } ( 1 .. $rows ) ] );
62 $schema->resultset ('Artist')->search ({ name => { -like => 'populateX%' } })->count,
64 'populate created correct number of rows with massive AoA bulk insert',
68 my $rs=$schema->resultset('Artist')->search({});
70 my $t0=[gettimeofday];
71 $count++ while $rs->next;
72 is($count,$rows,'get all the rows (loop)');
73 diag('Time for all(loop): '.tv_interval($t0));
77 my $rs=$schema->resultset('Artist')->search({});
78 my $t0=[gettimeofday];
80 diag('Time for first: '.tv_interval($t0));
84 my $rs=$schema->resultset('Artist')->search({});
85 my $t0=[gettimeofday];
87 is(scalar(@rows),$rows,'get all the rows (all)');
88 diag('Time for all: '.tv_interval($t0));