Query Plans - Firebird

Before a query is executed, a set of preparation routines—known as the optimizer—begins analyzing the columns and operations in the request, to calculate the fastest way to respond. It starts by looking for indexes on the tables and columns involved. Working its way through a sequence of cost-based decision paths, it develops a plan—a kind of “road map” for the route it will follow when it actually executes the query. The final plan it chooses reflects the “cheapest” route it can predict according to the indexes it can use. The optimizer’s plan can be viewed in an isql shell session in two ways:

  • By default, isql does not display the plan. Use SET PLAN ON to have the plan displayed at the top of the output from a SELECT query.
  • Use SET PLANONLY to submit queries and view the plans without actually running the queries. This enables you to inspect the plan for any query, not just SELECT queries.

It is possible to override the optimizer’s plan with one of your own, by including a PLAN clause in your query statement. Most third-party GUI tools provide the ability to view the plan, with or without running the query, and to override it.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics