05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

566<br />

CHAPTER 13 ■ PARTITIONING<br />

pieces of an object. However, in an OLTP environment, you are not full scanning large objects<br />

(if you are, you have a serious design flaw). Even if you partition your indexes, any increase in<br />

performance achieved by scanning a smaller index will be miniscule—if you actually achieve<br />

an increase in speed at all. If some of your queries use an index <strong>and</strong> they cannot eliminate all<br />

but one partition from consideration, you may find your queries actually run slower after partitioning<br />

since you now have 5, 10, or 20 small indexes to probe, instead of one larger index.<br />

We will investigate this in much more detail shortly when we look at the types of partitioned<br />

indexes available to us.<br />

Having said all this, there are opportunities to gain efficiency in an OLTP system with<br />

partitions. For example, they may be used to increase concurrency by decreasing contention.<br />

They can be used to spread out the modifications of a single table over many physical partitions.<br />

Instead of having a single table segment with a single index segment, you might have<br />

20 table partitions <strong>and</strong> 20 index partitions. It could be like having 20 tables instead of 1, hence<br />

contention would be decreased for this shared resource during modifications.<br />

As for parallel operations, as we’ll investigate in more detail in the next chapter, you do<br />

not want to do a parallel query in an OLTP system. You would reserve your use of parallel<br />

operations for the DBA to perform rebuilds, create indexes, gather statistics, <strong>and</strong> so on. The<br />

fact is that in an OLTP system, your queries should already be characterized by very fast index<br />

accesses, <strong>and</strong> partitioning will not speed that up very much, if at all. This does not mean that<br />

you should avoid partitioning for OLTP; it means that you shouldn’t expect partitioning to<br />

offer massive improvements in performance. Most OLTP applications are not able to take<br />

advantage of the times where partitioning is able to enhance query performance, but you can<br />

still benefit from the other two possible partitioning benefits; administrative ease <strong>and</strong> higher<br />

availability.<br />

Data Warehouse Systems<br />

In a data warehouse/decision-support system, partitioning is not only a great administrative<br />

tool, but also something that will speed up processing. For example, you may have a large<br />

table on which you need to perform an ad hoc query. You always do the ad hoc query by sales<br />

quarter, as each sales quarter contains hundreds of thous<strong>and</strong>s of records <strong>and</strong> you have millions<br />

of online records. So, you want to query a relatively small slice of the entire data set, but<br />

it is not really feasible to index it based on the sales quarter. This index would point to hundreds<br />

of thous<strong>and</strong>s of records, <strong>and</strong> doing the index range scan in this way would be terrible<br />

(refer to Chapter 11 for more details on this). A full table scan is called for to process many of<br />

your queries, but you end up having to scan millions of records, most of which won’t apply<br />

to our query. Using an intelligent partitioning scheme, you can segregate the data by quarter<br />

such that when you query the data for any given quarter, you will full scan only that quarter’s<br />

data. This is the best of all possible solutions.<br />

In addition, in a data warehouse/decision-support system environment, parallel query is<br />

used frequently. Here, operations such as parallel index range scans or parallel fast full index<br />

scans are not only meaningful, but also beneficial to us. We want to maximize our use of all<br />

available resources, <strong>and</strong> parallel query is a way to do it. So, in this environment, partitioning<br />

st<strong>and</strong>s a very good chance of speeding up processing.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!