01.09.2016 Views

Beginning Oracle Database 11g Administration From Novice to Professional

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

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

CHAPTER 17 SQL TUNING 385<br />

much time and attention <strong>to</strong> individual statements. The amount of effort we are willing <strong>to</strong><br />

expend is usually governed by business requirements and the return on our investment.<br />

The most frequently cited cause of inefficient SQL is the failure of the query optimizer<br />

<strong>to</strong> generate an efficient query execution plan, but there are many others. Here are<br />

some examples:<br />

<br />

equally efficient. In Chapter 2, you saw ten solutions <strong>to</strong> the problem of listing the<br />

status of all suppliers who supply hammers. Failure <strong>to</strong> use advanced features of<br />

the language is a common cause of inefficient SQL.<br />

<br />

SQL. For example, giving users the ability <strong>to</strong> generate new types of queries (a.k.a.<br />

ad hoc queries) is usually a perfect recipe for poor performance. Another example<br />

of poor application development practices is insufficient testing.<br />

<br />

Examples are inadequate indexing and partitioning of data, and insufficient attention<br />

<strong>to</strong> disk layouts.<br />

<br />

time passes. A perfect example is the absence of an archiving strategy <strong>to</strong> keep the<br />

amount of data under control.<br />

It bears repeating that hardware limitations—including CPU speed, memory size,<br />

and disk speed—play a big role in performance. If the system does not have enough<br />

memory, data may have <strong>to</strong> be frequently retrieved from disk. The workload handled by<br />

the database server also plays a major role in performance; your SQL statement will run<br />

slowly if it has <strong>to</strong> compete for resources with SQL statements submitted by other users.<br />

Often this is the result of poor coordination of workloads. For example, it is poor practice<br />

<strong>to</strong> perform batch processing during the day when most OLTP work is performed. Sometimes<br />

this is the result of poor capacity planning. For example, an online s<strong>to</strong>re may not<br />

have properly planned for the increase in transaction volumes during popular holidays.<br />

Ways <strong>to</strong> Improve SQL<br />

Given enough time, effort, and money, it is usually possible <strong>to</strong> extract more performance<br />

out of any SQL statement. However, it is not usually possible <strong>to</strong> give so much time and<br />

attention <strong>to</strong> individual statements. The amount of effort we are willing <strong>to</strong> expend is usually<br />

governed by business requirements and the return on our investment. The goal<br />

is usually <strong>to</strong> bring performance of poorly performing SQL statements <strong>to</strong> a level that is<br />

acceptable <strong>to</strong> the users of the database. The following sections describe some techniques<br />

that can be used <strong>to</strong> improve performance.

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

Saved successfully!

Ooh no, something went wrong!