A query plan (or query execution plan) is an ordered set of steps used to access information in a SQL Relational database management system. This is a specific case of the Relational model concept of Access plans. Please note that the term query in this case does not imply only reading information, it refers to finding the information so that it might be retrieved, or changed.
When a query is submitted to the database, the query optimizer evaluates all of the different possible plans for executing the query and returns what it considers the best option.
Query plans are a very important tool in performance tuning of a query or database.
Database tuning
Reviewing the query plan you can find opportunities for new indexes or changes to existing indexes. You might also find that the database is not properly taking advantage of existing indexes (see query optimizer).
Query tuning
The query optimizer will not always choose the best query plan for a given query. In some databases you can review the query plan, find problems, and then give the query optimizer hints on how to improve it. In other databases you can try alternate ways of expressing the same query (other queries that return the same results).
Last updated: 08-22-2005 06:49:16