Question

I have a few questions about optimizing this type of load.

One builds a new table of data to be loaded into a partitioned table and then builds the indexes on this new table.

  1. Should you build the index with the COMPUTE STATISTICS option or use the Cascade option of the DBMS_Stats?

  2. Should you gather stats on the table before the swap or on the partition after the swap?

  3. If you do it after the swap and you specify the partition name in the parameter list, what interplay does the granularity parameter have? For instance, if I specify a partition name and then set granularity to 'GLOBAL AND PARTITION' does that do Global at all? Does it do just that one partition?

Was it helpful?

Solution

Should you build the index with the COMPUTE STATISTICS option or use the Cascade option of the DBMS_Stats?

If this is a data warehouse then first consider not gathering statistics at all, and using dynamic sampling. Second, if you do gather statistics then by all means use compute statistics on the index.

Should you gather stats on the table before the swap or on the partition after the swap?

Gather statistics on the new-data table before the swap to get partition statistics on the new data -- gather statistics on the partitioned table afterwards to gather table statistics

If you do it after the swap and you specify the partition name in the parameter list, what interplay does the granularity parameter have? For instance, if I specify a partition name and then set granularity to 'GLOBAL AND PARTITION' does that do Global at all? Does it do just that one partition?

See above.

Seriously, give no statistics and dynamic sampling a chance.

OTHER TIPS

  1. DBMS_STATS is considered the proper way to calculate statistics for this version. Building the index with the COMPUTE STATISTICS is doable, but usually you want to calculate all your stats at one time and take snapshots.

  2. You want to gather stats after the swap. This way the optimizer will make the best guess for executing queries using that partitions' data.

  3. Why would you put both?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top