If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > RUNSTATS on empty table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-18-09, 16:49
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
RUNSTATS on empty table

does it do any damage to do RUNSTATS on empty tables? My boss says yes, but I could not find anything in the db2 documentation to confirm this.

What if deleted many records from the tables - should not we do RUNSTATS to collect stats?

It would not take a lot of time to run REORG and RUNSTATS on all tables and indexes in our db, so if I do it for all tables/indexes in certain db straightforward (without reorgchk) would it do any damage?

Thanks
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #2 (permalink)  
Old 01-18-09, 16:57
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by MarkhamDBA
does it do any damage to do RUNSTATS on empty tables?
Certainly not. On the contrary: if the table stays empty for the coming weeks, it's better that the optimizer knows about the fact.
On the other hand, if the table will get repopulated soon, it's probably better to postpone the runstats until after that.

REORG on an empty table will probably return a warning. (At least, it does on z/OS.) But again, no harm.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #3 (permalink)  
Old 01-18-09, 18:12
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
thanks, Peter
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #4 (permalink)  
Old 01-18-09, 22:42
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you delete all the rows in a table and don't do a runstats, the worst that will happen is that DB2 will try to access the data via an index instead of a table scan. But since there won't be any index rows (since there are no data rows), that will not take any longer than a table scan.

The worst than can happen if you do a runstats when he table is empty, and then you add a lot of rows before a new runstats can be executed, is that DB2 will do a table scan instead of index access (which could be very bad performance).

So I would suggest that it “may” not a good idea to do runstats on an empty table (unless you are sure that runstats will be performed as soon as a lot of new rows will be added).

If a table frequently oscillates between zero (or a few) rows and a lot of rows, then altering a table to “volatile” may be a good idea (which forces DB2 to use default statistics as if the stats were set -1).

You will not find these conclusions in the documentation. You must understand how DB2 works and use your brains.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On