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 > Creating Index after reorg; Index optimal?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-08-09, 04:42
colmmagoo colmmagoo is offline
Registered User
 
Join Date: Aug 2004
Posts: 15
Creating Index after reorg; Index optimal?

Hi, if you create an index after a table reorg:

REORG TABLE T1;
CREATE INDEX I_T1 ON T1 (C1, C2, C3);

Is it safe to assume that the index is optimal? (as defined in DB2 Universal Database)

I would assume the answer to be yes, but are there any additional REORG parameters or other commands that would ensure the table (plus all indexes) is in an optimal state at the end of the above sql command sequence?
Reply With Quote
  #2 (permalink)  
Old 10-08-09, 04:50
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Yes, the index will be in optimal state right after you create it. That would be the same as if you reorged the table (which reorgs all the indexes automatically unless it is an "inplace" reorg). A table reorg actually rebuilds the index from scratch, just like a create index statement.
__________________
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
  #3 (permalink)  
Old 10-08-09, 07:29
colmmagoo colmmagoo is offline
Registered User
 
Join Date: Aug 2004
Posts: 15
Interesting, thanks for the insight about reorg rebuilding indexes. I'd assumed (incorrectly) that REORG on a table would not REORG the indexes, but know now its not the case (unless its an inplace REORG as you state).
Reply With Quote
  #4 (permalink)  
Old 10-08-09, 08:54
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
i m not able to get
inplace is used to reorg online
and reorg table tabname , is classic way which reorgs the table and indexes
means rebuild the indexes
--
as per marcus when we use inplace command it reorgs only the table and not the indexes ?? , kindly correct me on this
redgs
paul
Reply With Quote
  #5 (permalink)  
Old 10-08-09, 11:35
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Reply With Quote
  #6 (permalink)  
Old 10-08-09, 12:35
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by Mathew_paul
..when we use inplace command it reorgs only the table and not the indexes ?? , kindly correct me on this
redgs
paul
That is correct. The indexes obviously get updated with the new RIDs of the rows (which have been moved via the reorg of the table), but the index itself does not get completely reorged.
__________________
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
  #7 (permalink)  
Old 10-08-09, 16:13
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
Is the index optimal? What about if you are creating this new index or recreating old one and it is defined as CLUSTER? Then the table and index are not optimal.

Dave Nance
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