A query plan (or query execution plan) is an set of steps used to access information in a SQL relational database management system.
When a query is submitted to the database, the queryoptimizer evaluates some of the different, correct possible plans for executing the query and returns what it considers the best alternative.
In some databases the query plan can be reviewed, problems found, and then the queryoptimizer given hints on how to improve it.
en.wikipedia.org /wiki/Query_plan (623 words)
Microsoft SQL Server 7.0 Query Processor (Microsoft SQL Server 7 Technical Articles)(Site not responding. Last check: 2007-11-04)
Queryoptimization is the process of choosing the fastest execution plan.
Query execution is the process of executing the plan chosen during queryoptimization.
A syntax-based queryoptimizer creates a procedural plan for obtaining the answer to a SQL query, but the particular plan it chooses is dependent on the exact syntax of the query and the order of clauses within the query.
SQL - Wikipedia, the free encyclopedia (via CobWeb/3.1 planetlab2.georgetown.edu)(Site not responding. Last check: 2007-11-04)
Structured English Query Language ("SEQUEL") was designed to manipulate and retrieve data stored in System R. The acronym SEQUEL was later condensed to SQL because the word 'SEQUEL' was held as a trademark by the Hawker-Siddeley aircraft company of the UK.
However, it also makes it possible for SQL source code to be produced (and optimized) by software, leading to the development of a number of natural language database query languages, as well as 'drag and drop' database programming packages with 'object oriented' interfaces.
Translating the query into an efficient query plan is left to the database system, more specifically to the queryoptimizer.
Over time, as the optimizer learns more about the characteristics of the data in the database, the SQL Anywhere optimizer may choose a different access plan for execution because its estimates are more exact (see Section 4.2) or because the data distribution has changed due to update operations.
After the first query has run, and all the rows in the result have been retrieved, the SQL Anywhere optimizer analyzes its processing in an effort to learn about the characteristics of the `state' column in the employee table.
If the optimizer needs to estimate the selectivity of a predicate that includes a non-indexed column for which no prior statistics are available, it estimates the number of records satisfying the selection condition using a set of default selectivity estimates based on a uniform distribution of random data.
To specify the goal of the queryoptimizer for an individual SQL statement, use one of the hints in Table 14-3.
The queryoptimizer determines which execution plan is most efficient by considering available access paths and by factoring in information based on statistics for the schema objects (tables or indexes) accessed by the SQL statement.
The optimizer estimates the cost of each plan based on statistics in the data dictionary for the data distribution and storage characteristics of the tables, indexes, and partitions accessed by the statement.
The Columbia QueryOptimization Project is a joint research project of David Maier from the Oregon Graduate Institute and Leonard Shapiro from Portland State University.
Since the behaviour of the optimizer is complicated, it is difficult to debug or verify the process of optimization.
In queryoptimization, the problem is to find the cheapest plan for a given query, subject to a certain context.
By monitoring queries as they execute, the autonomic optimizer compares the optimizer's estimates with actual cardinalities at each step in a QEP, and computes adjustments to its estimates that may be used during future optimizations of similar queries.
Despite this, the optimizer assumes that the statistics reflect the current state of the database, that is, that the database characteristics are relatively stable, and it relies upon the user to know when any table has changed enough to warrant the expensive recollection of statistics.
Feedback gives the greatest improvement to the modeling of queries that are either repetitive or are similar to earlier queries, that is, queries for which the optimizer's model exploits the same statistical information.
This means that the Optimizer assigns a time cost to each query task and then chooses the least expensive list of tasks to perform that generates the intended result set.
A query is flagged for compiling when you save any changes to the query (or its underlying tables) and when the database is compacted.
Because the query performance analysis is closely tied to the Jet database engine, the Performance Analyzer suggests adding indexes only when the indexes will actually be used by the Jet database engine to optimize the query.
The MySQL queryoptimizer has several goals, but its primary aims are to use indexes whenever possible and to use the most restrictive index in order to eliminate as many rows as possible as soon as possible.
The optimizer will also do a quick check of the index to estimate how many entries will be used when determining whether the index should be used for constant comparisons.
If you run a query only once each of two different ways, you'll often find that the second query is faster just because information from the first query is still cached and need not actually be read from the disk.
Sql server query optimizer(Site not responding. Last check: 2007-11-04)
The disadvantage was that the optimizer did not take this reduction into account during the queryoptimization phase.
With the release of SQL Server 7.0, views were combined with constraints to allow the queryoptimizer to remove irrelevant tables from the query plan (ie...
Query hints, on the other hand, are more of a directive rather than a suggestion.
Optimizers are hard to build because for any given query, there can be a prohibitively large number of plans to choose from.
Typically, the complexity of optimization is handled by dividing optimization into two phases: a heuristic phase (called query rewriting) that narrows the space of plans to consider, and a cost-based phase that compares the relative merits of plans that lie in the narrowed space.
Typically, the goal of such extensions is to reuse the relational queryoptimizer as much as possible, both to save in development costs and to exploit the maturity of relational optimizer technology.
Query Optimization > Using Indexing(Site not responding. Last check: 2007-11-04)
Those are the kinds of issues that this chapter focuses on, with the goal of assisting you in optimizing the performance of your database system so that it processes your queries as quickly as possible.
In a single-table query, the number of values you need to examine per column is the number of rows in the table.
Under these circumstances, the index might never be used at all, because the queryoptimizer generally skips an index in favor of a full table scan if it determines that a value occurs in a large percentage of a table's rows.
If there are multiple tables to be joined in a query, the optimizer can produce better join plans if you have PI statistics for each table.
The reason for this is that when there are no statistics on a skewed column, the optimizer chooses to take a conservative course by assuming that a certain percentage of the data values will qualify for the query.
In conclusion, the more statistics available to the Teradata optimizer, and the more accurate and up-to-date those statistics are, the better able the optimizer will be to select the most efficient access methods for retrieving data.
www.teradata.com /t/page/115444 (1341 words)
K2 - Query Optimizer(Site not responding. Last check: 2007-11-04)
K2 has a flexible, extensible queryoptimizer which uses both rewrite rules and a cost model.
After a query has been translated into an abstract syntax tree, which K2 uses to represent queries internally, it is manipulated by applying a series of rewrite rules.
First, a collection of rules is applied which simplifies the query, by taking pieces expressed using certain kinds of tree nodes and replacing them with others.
Query Optimizer(Site not responding. Last check: 2007-11-04)
The optimizer is in general a System R style optimizer, as described in "Access Path Selection in a Relational Database Management System", Proceedings of the ACM-SIGMOD International Conference on Management of Data, June 1979.
See the text for a more detailed description of queryoptimization and the associated cost formulas.
Note that the optimizer may have had some changes since these plans were generated, so your results may not be identical.
Abstract: We demonstrate a Web QueryOptimizer (WQO) within an architecture of mediators and wrappers, for WebSources of limited capability in a wide area environment.
The WQO has several innovative features including a CBR (capability based rewriting) Tool, an enhanced randomized relational optimizer extended to a Web environment, and a WebWrapper cost model that can provide relevant metrics for accessing WebSources.
Efficient Evaluation of Queries in a Mediator for..
Study various techniques for writing high-performance queries that allow the optimizer to use the most efficient query plan, and learn how to diagnose and correct performance problems with existing queries.
Gain proficiency in interpreting and modifying optimizer statistics to improve query performance and using simulated statistics for “what if” analysis.
The Adaptive Server QueryOptimizer, showplan and other Sybase utilities, optimizing joins, optimizer statistics, abstract plans, tuning insert, update, and delete operations, parallel query plans, using indexes to reduce I/O, and Stored Procedures.