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 > Question on reorgs

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-05, 08:40
SnowCrash7 SnowCrash7 is offline
Registered User
 
Join Date: Mar 2004
Posts: 42
Question on reorgs

I have a question concerning reorgs.

We have a relatively new DB2 system (8.1) on Aix 5.1 and we are trying to institute regular reorgs via scripts.

Does it matter if the index for a table or the table itself is reorganized first?

If the script reorganizes a table then follows that with a reorganize indexes all for that table is that a problem?

Right now the script issues in a loop

db2 -v "reorg table SIEBEL.$i"

followed by

db2 -v "reorg indexes all for table SIEBEL.$i"


I’m wondering if that is a problem.

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 01-10-05, 10:22
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
When an index is organised first, you will read less pages, if you want
to cluster the table data based on that index.
There are also other advantage of doing the index reorg first, based on that you have a clean and concise index structure.

regards.

Mujeeb
Reply With Quote
  #3 (permalink)  
Old 01-10-05, 13:47
dbamota dbamota is offline
Registered User
 
Join Date: Sep 2003
Posts: 237
Way I see it is if you reorg a table, page#,slot# are changed for some records, rendering all indexes invalid; that's why in a classic reorg, when you do a table reorg, inexes are also reorganized afterwards automatically.
__________________
mota
Reply With Quote
  #4 (permalink)  
Old 01-10-05, 14:46
SnowCrash7 SnowCrash7 is offline
Registered User
 
Join Date: Mar 2004
Posts: 42
Mota


I am testing using the syntax

db2 reorg table tablename allow no access

is that considered classic?

I then do a runstst with detailed and indexes all on the table and an index still shows as needing to be reorged.
Reply With Quote
  #5 (permalink)  
Old 01-10-05, 16:13
dbamota dbamota is offline
Registered User
 
Join Date: Sep 2003
Posts: 237
according to the first example under REORG INDEXES/TABLE in the COMMAND REFERENCE yours is a classic reorg. Why do you say your index needs a reorg; could you please post the snippet of your indexes indicating a reorg, from the reorgcheck report.
__________________
mota
Reply With Quote
  #6 (permalink)  
Old 01-11-05, 11:59
SnowCrash7 SnowCrash7 is offline
Registered User
 
Join Date: Mar 2004
Posts: 42
Apparently the indexes would show an out of cluster situation iunless they were designated in the reorg command to be used to order the table data.
thanks
Reply With Quote
  #7 (permalink)  
Old 01-11-05, 12:06
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
What I usually did , is that

1. run the reorgchk command, it will automatically update the statistics.

2. Reorg, if need arise.

2. run the reorgchk command without updating the statistics.

regards

Mujeeb
Reply With Quote
  #8 (permalink)  
Old 01-11-05, 13:02
dbamota dbamota is offline
Registered User
 
Join Date: Sep 2003
Posts: 237
When you update stats, tables are locked out. My preference is RUNSTATS ON TABLE tab1 ALLOW WRTE ACCESS; REORGCHK CURRENT STATISTICS ON TABLE ......; then a classic reorg; and again RUNSTATS ON TABLE tab1 ALLOW WRTE ACCESS; because the table is reorged and indexes altered, particularly the TYPE2 indexes in V8, a final runstats is necessary.
__________________
mota
Reply With Quote
  #9 (permalink)  
Old 01-12-05, 07:54
SnowCrash7 SnowCrash7 is offline
Registered User
 
Join Date: Mar 2004
Posts: 42
When doing an offline reorg, and you have a clustering index

is it best or even necessary to speciify the clustering index when you do the reorg
'reorg table using index'
Reply With Quote
  #10 (permalink)  
Old 01-13-05, 07:01
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
"For an inplace table reorg, if a clustering index is defined on the table and an index is specified, it must be clustering index. If the inplace option is not specified, any index specified will be used. If you do not specify the name of an index, the records are reorganized without regard to order. If the table has a clustering index defined, however, and no index is specified, then the clustering index is used to cluster the table. You cannot specify an index if you are reorganizing an MDC table."

Generally speaking, if you defined a clustering index, then that is the order you want to rows after a reorg and during insert operations, so I don't know why you would need to specify an index in the reorg statement if you have already defined a clustering index.
__________________
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