Up Prev Next
From: mpeppler at itf dot ch (Michael Peppler)
Subject: Running 'update statistics'
Date: Feb 1 1996 8:46AM
The little script below is quite usefull if you want too make sure that
your index distribution pages are correct (so that the optimizer will
do it's job as well as possible). What I do is I run 'update
statistics' on all the tables owned by 'dbo' in a database.
select(STDOUT); $| = 1; # Make sure output is un-buffered.
die "Please specify a database with -d 'dbname'...\n" if !defined($opt_d);
$dbh = new Sybase::DBlib 'sa', $password;
@tables = $dbh->sql("select o.name, u.name, o.id
from sysobjects o, sysusers u
where o.type = 'U' and u.uid = o.uid
and u.name = 'dbo'
order by o.name\n");
print "update statistics $$_\n";
$dbh->sql("update statistics $$_\n") ||
die "Update statistics failed for $$_\n";