View Single Post

   
  #5 (permalink)  
Old 03-28-2008, 04:39 AM
Sanjuro
 
Posts: n/a
Default Re: table changes since last runstats?

On Mar 19, 3:46 pm, Lennart <Erik.Lennart.Jons...@gmail.com> wrote:
> Probably a stupid question, but is there an easy way to determine how
> much a table has changed since last time stats where updated? What I'm
> trying to figure out is whether there is a need to do runstats on a
> particular table or not.
>
> Thanx
> /Lennart


The following may not work in all cases, might work best when a table
has changed a lot and has really old statistics, but might be worth a
try. If your systems are already on v9, then you should try Automatic
Runstats. I have them set to ON on my production systems and they have
been providing consistent worry-free maintenance.

Look at a plan of a recently executed SQL that accesses the table.
Above the table in question, you would see the card value for that
table. Do a select count(1)/count(*) on the table and see how much it
differs from the card value on the plan. If it differs by a lot then
the table needs runstats.

But this is only a case-by-case analysis when you are trying to fix a
bad query that now takes longer than its supposed to. I don't think
you can use this approach to prepare a regular maintenance plan. The
frequency and amount of data change in tables can only be accessed
properly by discussion with the application and data architects.

Cheers,
Sanjuro
Reply With Quote