Previous Table of Contents Next


Explain plans can be difficult to interpret. Indenting the explain steps greatly aids in the understanding of the order of the explain steps. The more common explain steps are discussed in Table 24.3.

Table 24.3. Explain plan steps.

Access Rule Description

AND-EQUAL Index values will be used to join rows.
CONCATENATION SQL statement UNION command.
FILTER FILTERs apply “other criteria” in the query to further qualify the matching rows. The “other criteria” include correlated subqueries, and HAVING clause.
FIRST ROW SQL statement will be processed via a cursor.
FOR UPDATE SQL statement clause “for update of” placed row level locks on affected rows.
INDEX (UNIQUE) SQL statement utilized a unique index to search for a specific value.
INDEX (RANGE SCAN) SQL statement contains a nonequality or BETWEEN condition.
HASH JOIN SQL statement initiated a hash-join operation.
MERGE JOIN SQL statement references two or more tables, sorting the two result sets being joined over the join columns and then merging the results via the join columns.
NESTED LOOPS This operation is one form of joining tables, as opposed to a merge join. One row is retrieved from the row source identified by the first child operation, and then joined to all matching rows in the other table, identified in the second child operation.
NONUNIQUE INDEX (RANGE SCAN) The RANGE SCAN option indicates that Oracle expects to return multiple matches (ROWIDs) from the index search.
PARTITION (CONCATENATED) SQL statement will access a partitioned object and merge the retrieved rows from the accessed partitions.
PARTITION (SINGLE) SQL statement will access a single partition.
PARTITION (EMPTY) The SQL statement makes reference to an empty partition.
SORT (ORDER BY) SQL statement contains an ORDER BY SQL command.
SORT (AGGREGATE) SQL statement initiated a sort to resolve a MIN or MAX type function.
SORT (GROUP BY) SQL statement contains a GROUP BY SQL command.
TABLE ACCESS (FULL) All rows are retrieved from the table without using an index.
TABLE ACCESS (BY ROWID) A row was retrieved from a table based on the ROWID of the row.
TABLE ACCESS (CLUSTER) A row is retrieved from a table that is part of an indexed cluster.
UNION SQL statement contains a DISTINCT SQL command.

Oracle8 has introduced three new columns: partition_start, partition_stop, and partition_id. These three new fields will aid in the tuning of SQL statements that access partitioned objects. partition_start and partition_stop show the range of partitions affected by this explain step. The partition_id is the identification number for that particular explain step.

Finally, there are both good and poor ways to code SQL statements. Here are some guidelines for SQL statement coding that will help both the rule-based and the cost-based optimizers.

DON’T use calculations in the WHERE clause on indexed columns. Unless the intended behavior is to disable the index use, any function on indexed columns will ignore the index.

DO use the IN operator instead of NOT. Try to avoid using the NOT command by using >=, <=, and so on.

DON’T use an index if more than 20 percent of the rows will be returned by the query.

DO use array processing whenever possible (Export and Pro*C applications).

DON’T use subqueries if other solutions exist (PL/SQL loop, for example).

DO use hints to ensure the desired execution-plan results.

DON’T write applications that use SQL execution-plan defaults. The Oracle Corporation makes no guarantees that default behavior will be maintained in future releases, or even between different hardware platforms.

Tuning Checklist

1.  Read the Oracle Installation Guide that comes with the distribution software.
2.  Make sure SHMMAX, SHMMHI, SEMMNI, SEMMNS, and SHMSEG are all set properly.
3.  Ensure that there is enough memory to avoid swapping but ensure maximum Oracle performance.
4.  The UNIX software, application software, and Oracle software should all be on separate disk drives.
5.  Make sure system level I/O is evenly distributed across all available disk drives.
6.  Tune the System Global Area (including the buffer cache, shared pool, log buffer, and sort area).
7.  Monitor and alleviate redo log and rollback segment contention.
8.  Distribute related objects (including referential integrity related objects) on different disk drives.
9.  Partition tables and indexes when possible.
10.  Monitor for extent interleaving, perform tablespace reorganizations as needed.
11.  Monitor and alleviate excessive row chaining and row migration.
12.  Recompile procedures, functions, packages, and triggers when they become invalidated.
13.  Utilize better SQL coding techniques.
14.  Use unrecoverable transactions for large “create table as” and data loads.
15.  Pin frequently used application code into the shared pool.
16.  Utilize bitmap indexes, star queries, histograms, hash joins, index-only tables, and reverse key indexes.
17.  Tune frequently used and resource-intensive SQL statements.

Summary

This chapter supplies the reader with an in-depth study of the four tuning levels associated with any Oracle environment: operating system tuning, Oracle RDBMS tuning, database design tuning, and SQL statement tuning. Each level depends on the other levels. Each level of tuning should be evaluated per application needs in the order listed in this chapter. There is no single magical solution to any performance issue, but Oracle provides a rich environment of options so that most any Oracle application can access data in the most optimal manner.


Previous Table of Contents Next
Используются технологии uCoz