01.09.2016 Views

Beginning Oracle Database 11g Administration From Novice to Professional

Create successful ePaper yourself

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

CHAPTER 7 PHYSICAL DATABASE DESIGN 135<br />

<br />

for example, no two employees can share a social security number. This is particularly<br />

true of any column or combination of columns designated as a primary key.<br />

foreign keys. A foreign key is a column or set<br />

of columns that is required <strong>to</strong> map <strong>to</strong> the primary key of another table. Full table<br />

scans and table- level locks can result if a foreign key is not indexed. 1<br />

<strong>Oracle</strong> <strong>Database</strong> <strong>11g</strong> provides several “advisors” that can generate recommendations<br />

for improving the performance of SQL queries; I will discuss them in detail in Chapter 17,<br />

which covers SQL tuning. Listing 7-1 provides an example of how the procedure<br />

can be used <strong>to</strong> analyze an SQL statement and determine if additional indexes<br />

would improve performance. In this case, the procedure recommends that<br />

a “function- based index” be created and even provides the necessary SQL commands <strong>to</strong><br />

do so; you can replace the system- generated name for the index with a more meaningful<br />

name. Note that you need the privilege in order <strong>to</strong> use the procedure.<br />

Listing 7-1. Using the Procedure <strong>to</strong> Analyze an SQL Query and Determine if Additional<br />

Indexes Should Be Created <strong>to</strong> Improve Performance<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

1. In Expert One-On-One <strong>Oracle</strong>, Tom Kyte says: “I sometimes wish I had a dollar for every time I was able<br />

<strong>to</strong> solve the insolvable hanging issue by simply running the query <strong>to</strong> detect un- indexed foreign keys and<br />

suggesting that we index the one causing the problem—I would be very rich.” Tom provides the script in<br />

the book—it can also be found at .

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

Saved successfully!

Ooh no, something went wrong!