Posted by: Peter Scott | October 15, 2007

Converting partition views to partitioned tables

A few days I was talking to a customer who has a legacy data warehouse, designed back in Oracle 7.3 days which relies extensively on partition views as a way of handling the volume of data involved (basket level sales from a national high-street chain). Over the years the underlying platform has changed and the database has been upgraded to Oracle 10g, but in that time the data-load code has not changed more than was needed to remain functional.

As you may know, partition views are a way of dividing up what would otherwise be a large table into a series of smaller tables that contain specific subsets of the data and then building a UNION ALL view over the small tables so that it appears that there is single table containing all of the data. From the view predicates and, sometimes, with the help of check constraints the query engine will be able to identify and access just the tables that contain the rows of interest, which is of course similar to partition elimination or pruning. Of course, this technology was the forerunner to the far more versatile partitioning introduced in Oracle 8i, but the old way still exists and still can be used.

Migrating from partition views to partition tables is not normally a big deal if you keep to the same partitioning scheme – basically you create an empty partitioned table and exchange each of the component tables into the partitioned table. You don’t even have to do the whole table in one go, it quite possible to make a partition view over as a union all of a partitioned table and the remaining (unconverted) tables.

The fun starts when you want to change the partitioning scheme! For example. suppose the system was designed for efficiency of batch with an empty table each day to receive the day’s transmission from the outlets, in effect range partitioned on data-load date. But in reality the only time people look at data-load date is during the batch process, the rest of the time people query on sales date. Often the two dates are the same, but in the real world network links go down ,stores get flooded, and for various reasons data can arrive several days late. So when we decide to migrate to partitioned tables perhaps we should also think about changing the key column for the partitioned table from load date to transaction date. But now our simplistic exchange conversion method won’t work so well as some data will need to move to other partitions as it arrived ‘late’. Given this scenario I would be very tempted to create a compressed partitioned table and to use an ordered direct-path load to populate the partitions from the source tables.

About these ads


  1. Actually, you can no longer use partitioned views from 10g onwards, as the parameter partition_view_enabled has been deprecated.

  2. The feature still works, but the parameter has gone, the default behaviour of the database in 10 g is as if partition_view_enabled was set to true.

    This can be quickly verified by examining a query plan for evidence of view-style table elimination. The testing of this feature was key to my customer making the move from 8i to 10 g.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s



Get every new post delivered to your Inbox.

%d bloggers like this: