by Markus Winand.

Optimizer - Query Optimizer - Query Planner


The Optimizer (Oracle), Query Optimizer (SQL Server, MySQL) or Query Planner (PostgreSQL) translates the SQL statement to an executable program, in form of an execution plan, very much like a compiler translates source code into an executable.

There are generally two kinds of Optimizers:

Rule Based Optimizer (RBO)

Rule Based Optimizers follow a strict set of rules to create an execution plan — e.g., always use an index if possible.

Cost Based Optimizer (CBO)

Cost Based Optimizers generate many different execution plans, apply a cost model to all of them and select the one with the best cost value for execution.

Cost Based Optimizers will, for example, compare the estimated cost for a query using an index to the cost reading the entire table. The optimizer may select the full table access if it the cost values suggest that the full table access is more efficient than the index lookup.

Cost Based Optimizers are the predominant implementation.

The major decisions done by Optimizers are:

  • Join Algorithm and Join Order selection

  • Index usage

Optimizers do not:

  • Optimize Tables or Indexes

  • Optimize obfuscated SQL

  • Defragment data

Previous pageNext page

You can’t learn everything in one day. Subscribe the newsletter via E-Mail, Bluesky or RSS to gradually catch up. Have a look at modern-⁠sql.com as well.

About the Author

Photo of Markus Winand

Markus Winand provides insights into SQL and shows how different systems support it at modern-sql.com. Previously he made use-the-index-luke.com, which is still actively maintained. Markus can be hired as trainer, speaker and consultant via winand.at.

Buy the Book

Cover of “SQL Performance Explained”: Squirrel running on grass

The essence of SQL tuning in 200 pages

Buy now!
(paperback and/or PDF)

Paperback also available at Amazon.com.

Hire Markus

Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »

Connect with Markus Winand

Subscribe mailinglistsSubscribe the RSS feedMarkus Winand on LinkedInMarkus Winand on XINGMarkus Winand on TwitterMarkus Winand on Bluesky
Copyright 2010-2025 Markus Winand. All righs reserved.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR