Query Tuning
The query optimizer will not always choose the best query plan for a given query. In some databases the query plan can be reviewed, problems found, and then the query optimizer given hints on how to improve it. In other databases alternatives to express the same query (other queries that return the same results) can be tried. Some query tools can generate embedded hints in the query, for use by the optimizer.
Some databases like Oracle provide a Plan table for query tuning. This plan table will return the cost and time for executing a Query. In Oracle there are 2 optimization techniques:
- CBO or Cost Based Optimization
- RBO or Rule Based Optimization
The RBO is slowly being deprecated. For CBO to be used, all the tables referenced by the query must be analyzed. To analyze a table, a package DBMS_STATS can be made use of.
The others methods for query optimization include:
- SQL Trace
- Oracle Trace
- TKPROF
- Video tutorial on how to perform SQL performance tuning with reference to Oracle
|
Read more about this topic: Query Plan
Famous quotes containing the word query:
“Such condition of suspended judgment indeed, in its more genial development and under felicitous culture, is but the expectation, the receptivity, of the faithful scholar, determined not to foreclose what is still a questionthe philosophic temper, in short, for which a survival of query will be still the salt of truth, even in the most absolutely ascertained knowledge.”
—Walter Pater (18391894)