SQL Tuning   «Prev  Next»

Lesson 10

Oracle SQL Tuning Conclusion

As you can see, there is quite a bit of complexity to SQL Tuning.
. The following concepts were covered in this module:
  1. Oracle provides a standard ANSI SQL for database access, and has provided a wealth of built-in functions to improve SQL productivity.
  2. SQL tuning is one of the single most important tuning techniques that can be used to tune an Oracle database.
  3. Oracle provides a set of tools to assist in tuning SQL, including EXPLAIN PLAN, TKPROG and SQL Analyzer.
  4. Oracle has two optimizer modes. Rule-based optimization is the oldest method and relies on heuristics to determine access paths. The cost-based optimizer is a later development and relies on table and index statistics to formulate access plans to data.
  5. The EXPLAIN PLAN utility is the primary method for viewing the underlying access path to Oracle tables and indexes.
  6. Oracle provides hints that can be added to standard SQL to change the access path to data.

Tuning a single SQL query is an enormously important topic. Before going into production, virtually every system would expose some statements which required tuning.

Access and Filter Predicates

Syntactically, SQL query consists of three fundamental parts:
  1. a list of columns,
  2. a list of tables, and
  3. a "where" clause.
The "where" clause is a logical formula that can be further decomposed into predicates connected by Boolean connectives.
For example, the "where" clause of:
select empno, sal from emp e, dept d
where e.deptno = d.deptno and dname = 'ACCOUNTING'

Is a conjunction of dname = 'ACCOUNTING' single table predicate and e.deptno = d.deptno join predicate. In my opinion, predicate handling is the heart of SQL optimization: predicates could be transitively added, rewritten using Boolean Algebra laws, and moved around at SQL Execution Plan. In our simplistic example, the single table predicate is applied either to index or table scan plan nodes, while join predicate could also be applied to the join node. Unfortunately, despite their significance, Oracle Execution Plan facility didn't show predicates until version 9.2.

This module has served as a high level introduction to the advanced SQL tuning topics that will follow in the later modules.
Topics in this module include:
  1. Oracle extensions to ANSI standard SQL
  2. Basic SQL tuning tools
  3. Using the EXPLAIN PLAN utility
  4. The SQL optimizer modes
  5. The rule-based SQL optimizer
  6. The cost-based SQL optimizer
  7. Tuning SQL with hints

New Terms

Here are the terms from this module that may have been new to you:
  1. ANSI standard: The American National Standards Institute
  2. BIF: Extensions to standard Oracle SQL
  3. Cost-based optimizer: This is the latest SQL optimizer that uses object statistics to make intelligent table access decisions.
  4. Driving table: This is the table used by the SQL optimizer in the initial step of execution.
  5. Full-table scan: This is an execution plan that accesses a table without an index, reading each block of the table.
  6. Hash join: This is an execution plan that creates a hash table in SGA memory and uses this memory structure to join the tables.
  7. Heuristic: This is a rule or set of rules used to describe a process.
  8. Hint: This is an SQL compiler directive that tells Oracle to change an execution plan.
  9. Index: This is a data structure used to facilitate fast access to table rows in a specified sequence.
  10. Optimizer: This is an Oracle tool used to determine Oracle SQL execution plans.
  11. Ranking scheme: This is a method for determining the relative costs among candidate execution plans.
  12. Rule-based optimizer: This is the first Oracle SQL optimizer; it uses general rules to formulate execution plans.
Now that we know the basics, we will move on to look at advanced Oracle locking topics.
In the next module, we will explore the implementation of the ANSI standard.

SQL Tuning Concepts - Quiz

To complete this module, click the Quiz link below to test your knowledge so far of Oracle concepts and tuning.
SQL Tuning Concepts - Quiz

SEMrush Software