Re: update statistics
Posted in 2007
Obnoxio The Clown wrote:
> Actually, I'd be inclined to go with a simple UPDATE STATISTICS LOW for
> all tables and only muck around with other stats if you have a query that
> runs badly.
>
> Following the guidelines shouldn't harm anything, but it may be irrelevant.
>
Something in the middle of "simple" and "complex", probably nearer
simple ...
unload to update_stats.sql delimiter ";"
select "update statistics low drop distributions"||""||"" from
systables where tabid = 1
union ALL
select unique "update statistics medium for table"||t.tabname||"("||trim(c.colname)||")"
from sysindexes i, syscolumns c, systables t
where i.tabid > 99
and i.tabid = c.tabid
and i.tabid = t.tabid
and c.colno in (
i.part2, i.part3, i.part4, i.part5, i.part6, i.part7, i.part8,
i.part9,
i.part10, i.part11, i.part12, i.part13, i.part14, i.part15, i.part16)
and tabtype = 'T'
and c.colno not in (select i1.part1 from sysindexes i1 where i1.tabid =
t.tabid)
union ALL
select unique "update statistics high for table"||t.tabname||"("||trim(c.colname)||")"
from sysindexes i, syscolumns c, systables t
where i.tabid > 99
and i.tabid = c.tabid
and i.tabid = t.tabid
and i.part1 = c.colno
and tabtype = 'T'
union ALL
select "update statistics for procedure"||""||"" from systables
where tabid = 1;