Informix 7.30UC7XH Update Statistics
Posted in 1999
Topics: General Discussion
I've got a 100GB DB (with 500 tables and 700 indexes). We need to refresh the whole database and do an update statistics on the last step. Please help me out to determine which one is the best to choose if I just have 24 hours to finish this update statistics: 1) update statistics; 2) update statistics for table "table name"; 3) set pdq priority to 100 and update statistics; 4) set pdq priority to 100 and update statistics for each table; or 5) what else you can think of. -- DK/MJ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.
I've had some good luck updating statistics in parallel; i.e., running around 3 to 5 simultaneous batch processes, each running at pdqpriority high. Rich "M. Jiwani" wrote: > I've got a 100GB DB (with 500 tables and 700 indexes). > We need to refresh the whole database and do an update > statistics on the last step. > > Please help me out to determine which one is the best > to choose if I just have 24 hours to finish this update > statistics: > 1) update statistics; > 2) update statistics for table "table name"; > 3) set pdq priority to 100 and update statistics; > 4) set pdq priority to 100 and update statistics for each > table; or > 5) what else you can think of. > > -- > DK/MJ > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. -- Richard C. Auslander Database Manager AirFlash, Inc. 1733 Woodside Rd., Suite #110 Redwood City, CA 94061 (650) 556-7928 www.airflash.com
I would do seperate updates for each table .. however you need a better
strategy than the one mentioned..
e.g. for a table with a primary key index something like
update statistics medium for table <tablename> distributions only;
update statistics high for table <tablename>(<primary key>)
M. Jiwani <mjiwani@my-deja.com> wrote in message
news:7nii11$vkj$1@nnrp1.deja.com...
> I've got a 100GB DB (with 500 tables and 700 indexes).
> We need to refresh the whole database and do an update
> statistics on the last step.
>
> Please help me out to determine which one is the best
> to choose if I just have 24 hours to finish this update
> statistics:
> 1) update statistics;
> 2) update statistics for table "table name";
> 3) set pdq priority to 100 and update statistics;
> 4) set pdq priority to 100 and update statistics for each
> table; or
> 5) what else you can think of.
>
>
>
> --
> DK/MJ
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0080">
<tt>here is my perl program for update statistics....</tt>
<br><tt>use it all if you like... god knows this news group has helped
me enough..</tt>
<br><tt>it does a low, then a medium distibutions only, then a high on
lead colums then on procedures.</tt>
<br><tt>you need to change occurances of <i><u>dbaccess tepr</u></i> to
your database name....</tt>
<br><tt>feedback is welcome.</tt>
<br>
<hr WIDTH="100%">
<br><tt>#!/users/arichard/bin/perl/perl</tt>
<br><tt>######################################################</tt>
<br><tt># written by Adam B. Richards 4/1999</tt>
<br><tt>######################################################</tt>
<br><tt>$|=1;</tt>
<br><tt>######################################################</tt>
<br><tt># set the ifmx environmental settings</tt>
<br><tt>$ENV{PDQPRIORITY} =10;</tt>
<br><tt>$ENV{PSORT_NPROCS}=5;</tt>
<br><tt>$colmode='high';</tt>
<br><tt>######################################################</tt>
<br><tt>print `date`."\\n";</tt>
<br><tt>######################################################</tt>
<br><tt>$up_low_cmd='dbaccess tepr << EOT</tt>
<br><tt>-- first run a low</tt>
<br><tt>update statistics low;</tt>
<br><tt>EOT</tt>
<br><tt>';</tt>
<br><tt>print $up_low_cmd;print `$up_low_cmd`;</tt>
<br><tt>######################################################</tt>
<br><tt>$up_med_cmd='dbaccess tepr << EOT</tt>
<br><tt>-- first run a medium on table data only (no indexes)</tt>
<br><tt>update statistics medium for table distributions only;</tt>
<br><tt>EOT</tt>
<br><tt>';</tt>
<br><tt>print $up_med_cmd;print `$up_med_cmd`;</tt>
<br><tt>######################################################</tt>
<br><tt>$idxcmd='dbaccess tepr << EOT</tt>
<br><tt>-- select a.tabname, b.tabid, b.idxname, b.part1, c.colname
from</tt>
<br><tt>select distinct a.tabname table, "|" d, c.colname pidxcol
from</tt>
<br><tt>systables a, sysindexes b, syscolumns c</tt>
<br><tt>where</tt><tt></tt>
<p><tt>b.tabid = a.tabid</tt>
<br><tt>and</tt>
<br><tt>b.tabid = c.tabid</tt>
<br><tt>and</tt>
<br><tt>b.part1 = c.colno</tt>
<br><tt>and</tt>
<br><tt>a.tabid > 99;</tt>
<br><tt>EOT</tt>
<br><tt>';</tt>
<br><tt>@idxlist= `$idxcmd`;</tt>
<br><tt>j:foreach $i (@idxlist)</tt>
<br><tt> {</tt>
<br><tt> $t = &trim($i);</tt>
<br><tt> if (length($t)<=0)
{ next j;}# ignore blank lines</tt>
<br><tt> if ($t=~m/d pidxcol/)
{next j;} #ignore header</tt>
<br><tt> chomp($t);</tt>
<br><tt> ($table,$col)=split('\\|',$i);</tt>
<br><tt> $table=&trim($table);
$col=&trim($col);</tt>
<br><tt> $ccmd='dbaccess tepr
<< EOT</tt>
<br><tt>update statistics '.$colmode.' for table '.$table.' ('.$col.');</tt>
<br><tt>EOT';</tt>
<br><tt>print "---- START: ".`date`."\\n";</tt>
<br><tt>print $ccmd;print `$ccmd`;</tt>
<br><tt> }</tt>
<br><tt>######################################################</tt>
<br><tt>$arcmd='dbaccess tepr << EOT</tt>
<br><tt>-- update stats on the stored procedures last</tt>
<br><tt>update statistics for procedure;</tt>
<br><tt>EOT</tt><tt></tt>
<p><tt>';</tt>
<br><tt>print $arcmd;print `$arcmd`;</tt>
<br><tt>######################################################</tt>
<br><tt>print `date`."\\n";</tt>
<br><tt>######################################################</tt>
<br><tt>sub trim</tt>
<br><tt>{</tt>
<br><tt> my @out = @_;</tt>
<br><tt> for (@out){</tt>
<br><tt> s/^\\s+//;</tt>
<br><tt> s/\\s+$//;</tt>
<br><tt> }</tt>
<br><tt>return wantarray ? @out : $out[0];</tt>
<br><tt>}</tt>
<br><tt>###########################################</tt>
<br>
<hr WIDTH="100%"><tt></tt>
<p><tt>Paul Wilson wrote:</tt>
<blockquote TYPE=CITE><tt>I would do seperate updates for each table ..
however you need a better</tt>
<br><tt>strategy than the one mentioned..</tt><tt></tt>
<p><tt>e.g. for a table with a primary key index something like</tt><tt></tt>
<p><tt>update statistics medium for table <tablename> distributions
only;</tt>
<br><tt>update statistics high for table <tablename>(<primary key>)</tt><tt></tt>
<p><tt>M. Jiwani <mjiwani@my-deja.com> wrote in message</tt>
<br><tt><a href="news:7nii11$vkj$1@nnrp1.deja.com">news:7nii11$vkj$1@nnrp1.deja.com</a>...</tt>
<br><tt>> I've got a 100GB DB (with 500 tables and 700 indexes).</tt>
<br><tt>> We need to refresh the whole database and do an update</tt>
<br><tt>> statistics on the last step.</tt>
<br><tt>></tt>
<br><tt>> Please help me out to determine which one is the best</tt>
<br><tt>> to choose if I just have 24 hours to finish this update</tt>
<br><tt>> statistics:</tt>
<br><tt>> 1) update statistics;</tt>
<br><tt>> 2) update statistics for table "table name";</tt>
<br><tt>> 3) set pdq priority to 100 and update statistics;</tt>
<br><tt>> 4) set pdq priority to 100 and update statistics for each</tt>
<br><tt>> table; or</tt>
<br><tt>> 5) what else you can think of.</tt>
<br><tt>></tt>
<br><tt>></tt>
<br><tt>></tt>
<br><tt>> --</tt>
<br><tt>> DK/MJ</tt>
<br><tt>></tt>
<br><tt>></tt>
<br><tt>> Sent via Deja.com <a href="http://www.deja.com/">http://www.deja.com/</a></tt>
<br><tt>> Share what you know. Learn what you don't.</tt></blockquote>
<tt></tt><tt></tt>
<p><tt>--</tt>
<br><tt>Adam Richards, MCI WorldCom - V622-1328 - 719-535-1328</tt>
<br><tt>WWW: <A HREF="http://166.37.1.157/">http://166.37.1.157/</A></tt>
<br><tt>EMAIL: adam.richards@wcom.com</tt>
<br><tt></tt>
</body>
</html>
"M. Jiwani" wrote:
>
> I've got a 100GB DB (with 500 tables and 700 indexes).
> We need to refresh the whole database and do an update
> statistics on the last step.
>
> Please help me out to determine which one is the best
> to choose if I just have 24 hours to finish this update
> statistics:
> 1) update statistics;
> 2) update statistics for table "table name";
> 3) set pdq priority to 100 and update statistics;
> 4) set pdq priority to 100 and update statistics for each
> table; or
> 5) what else you can think of.
Get my dostats.ec utility from the IIUG Software Repository and run 5-10 copies,
on
different tables, at once with PDQPRIORITY=100/(#copies). Here is an ksh/awk
script
to create the script to run all the needed dostats in parallel groups:
#! /usr/bin/ksh
if [[ $# -lt 2 ]]; then
echo Usage: $0 database #copies <table_template>
exit 1
fi
dbase=$1
ncopies=$2
if [[ $# -eq 3 ]]; then
templ=$3
else
templ='*'
fi
dbaccess $dbase - <<EOF 2>/dev/null
output to temp$$ without headings
select tabname
from systables
where tabid > 99
and tabname matches "$templ";EOF
awk -v ncopies=$ncopies -v dbase=$dbase '
BEGIN {
cnt=0;
pdq=100/ncopies;
printf "PDQPRIORITY=%d; export PDQPRIORITY \\n", pdq;
}
{
if (length( $1 ) == 0){ next; }
}
{
# Every N copies of dostats insert a wait
if ((cnt % ncopies) == 0 && cnt > 0) { print "wait"; }
# output a dostats command for each table in the background
printf "dostats -d %s -t %s & \\n", dbase, $1, pdq;
cnt++;
}
END {
# Now update stats on all stored procedures.
print "dostats -d %s -p \\n", dbase;
}
' temp$$
##### End script #####
Then to generate a multiple dostats script, assume you named the above genstats:
genstats mydatabase 5 >updstats.sh
Art S. Kagel