![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, Let's say I have a large table which needs to be reloaded from scratch with (lots of) new data. The table has a clustering index and a few ordinary indexes. The table needs to be put in an optimal state for subsequent work (which includes minor updates once in a while). What's the proper way to go? Sequence a: 0. (Leave the indexes: Don't drop indexes before load.) 1. Load data (in replace mode). 3. RUNSTATS ON TABLE ... AND INDEXES ALL to speed up the subsequent table re-organization? 4. Reorg table to make the clustering index have its influence. (Or will LOAD be able to cluster data while loading, knowing that there is clustering index?) 5. RUNSTATS ON TABLE ... AND INDEXES ALL again to let the database know about the new situation. 6. Reorg indexes. 7. RUNSTATS ON TABLE ... AND INDEXES ALL again to let the database know about the new situation. Regarding sequence a: Maybe some RUNSTATS steps aren't needed? Sequence b (like a, but drop indexes before load): 0. Drop indexes. 1. Load data (in replace mode). 2. Create indexes. 3-7 as above. |
|
Regarding sequence b: - According to the documentation, by default, indexing mode is AUTOSELECT. And given that replace mode is being used, AUTOSELECT should be clever enough to choose complete index rebuilds, right? |
|
- One would think that index creation would provide a lot of statistics information to the database; can the database use this knowledge, such that the runstats in step 3 is implied? |
#3
| |||||
| |||||
|
|
First of all, you don't need to do step 6. If you do a classic (offline) reorg, it will automatically rebuild all indexes for you. |
|
Second, you only need to do RUNSTATS once, at the end of the process. |
|
If indexes exist on the table when you do a LOAD REPLACE, DB2 will build temporary tables for each index *in parallel* during the load phase. |
|
- One would think that index creation would provide a lot of statistics information to the database; can the database use this knowledge, such that the runstats in step 3 is implied? This is true; and when you create an index you can specify COLLECT [DETAILED] STATISTICS. |
|
Bottom line: [...] |
#4
| |||
| |||
|
|
That's new to me. By "offline" you mean stating "USE <some tmpspace>", right? |
|
But will REORG not run faster if there are statistics available to help the re-organization? |
|
Does this mean that the table will be copied in full n times (n being the number of indexes), i.e. even including columns which are not part of the index? |
![]() |
| Thread Tools | |
| Display Modes | |
| |