5 refresh_matviews.pl - run PL/pgSQL functions to do a basic or concurrent refresh of all database materialized views
9 refresh_matviews.pl -H [database handle] -D [database name] -c [to run concurrent refresh]
15 -c flag; if present, run concurrent refresh
17 All materialized views that are included in the refresh function will be refreshed
18 If -c is used, the refresh will be done concurrently, a process that takes longer than a standard refresh but that is completed without locking the views.
22 Bryan Ellerbrock <bje24@cornell.edu>
30 #use CXGN::DB::InsertDBH;
32 our ($opt_H, $opt_D, $opt_U, $opt_P, $opt_c, $refresh);
35 print STDERR
"Connecting to database...\n";
36 my $dsn = 'dbi:Pg:database='.$opt_D.";host=".$opt_H.";port=5432";
37 my $dbh = DBI
->connect($dsn, $opt_U, $opt_P);
40 my $q = "UPDATE public.matviews SET currently_refreshing=?";
42 my $h = $dbh->prepare($q);
45 print STDERR
"Refreshing materialized views . . ." . localtime() . "\n";
48 $refresh = 'SELECT refresh_materialized_views_concurrently()';
50 $refresh = 'SELECT refresh_materialized_views()';
53 $h = $dbh->prepare($refresh);
54 my $status = $h->execute();
56 print STDERR
"Materialized views refreshed! Status: $status" . localtime() . "\n";
58 $q = "UPDATE public.matviews SET currently_refreshing=?";
60 $h = $dbh->prepare($q);
68 print STDERR
"Done, exiting refresh_matviews.pl \n";