05.11.2015 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 11<br />

■ ■ ■<br />

Indexes<br />

Indexing is a crucial aspect of your application design <strong>and</strong> development. Too many indexes<br />

<strong>and</strong> the performance of DML will suffer. Too few indexes <strong>and</strong> the performance of queries<br />

(including inserts, updates, <strong>and</strong> deletes) will suffer. Finding the right mix is critical to your<br />

application’s performance.<br />

Frequently, I find that indexes are an afterthought in application development. I believe<br />

that this is the wrong approach. From the very beginning, if you underst<strong>and</strong> how the data will<br />

be used, you should be able to come up with the representative set of indexes you will use in<br />

your application. Too many times the approach seems to be to throw the application out there<br />

<strong>and</strong> then see where indexes are needed. This implies you have not taken the time to underst<strong>and</strong><br />

how the data will be used <strong>and</strong> how many rows you will ultimately be dealing with. You’ll<br />

be adding indexes to this system forever as the volume of data grows over time (i.e., you’ll perform<br />

reactive tuning). You’ll have indexes that are redundant <strong>and</strong> never used, <strong>and</strong> this wastes<br />

not only space but also computing resources. A few hours at the start spent properly considering<br />

when <strong>and</strong> how to index your data will save you many hours of “tuning” further down the<br />

road (note that I said doing so “will,” not “might,” save you many hours).<br />

The basic aim of this chapter is to give an overview of the indexes available for use in<br />

<strong>Oracle</strong> <strong>and</strong> discuss when <strong>and</strong> where you might use them. This chapter differs from others in<br />

this book in terms of its style <strong>and</strong> format. Indexing is a huge topic—you could write an entire<br />

book on the subject—in part because indexing bridges the developer <strong>and</strong> DBA roles. The<br />

developer must be aware of indexes, how indexes apply to their applications, when to use<br />

indexes (<strong>and</strong> when not to use them), <strong>and</strong> so on. The DBA is concerned with the growth of<br />

an index, the use of storage within an index, <strong>and</strong> other physical properties. We will be tackling<br />

indexes mainly from the st<strong>and</strong>point of their practical use in applications. The first half of this<br />

chapter represents the basic knowledge I believe you need to make intelligent choices about<br />

when to index <strong>and</strong> what type of index to use. The second half of the chapter answers some of<br />

the most frequently asked questions about indexes.<br />

The various examples in this chapter require different feature releases of <strong>Oracle</strong>. When a<br />

specific example requires features found in <strong>Oracle</strong> Enterprise or Personal Edition but not<br />

St<strong>and</strong>ard Edition, I’ll specify that.<br />

421

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

Saved successfully!

Ooh no, something went wrong!