Query Optimization is all about finding the query plan that minimizes the number of I/Os it takes to execute the query.

Introduction

We cannot know how many I/Os a plan will cost until it’s executed. So:

  1. Impossible to guarantee that we will find the optimal query plan. We can only hope to find a good one using heuristics and estimations
  2. We need some way to estimate how much a query plan costs. (That’s done in Plan Cost Estimator)

Selectivity Estimation

  • Selectivity estimation is an approximation for what percentage of pages will make it through the operator onto the operator above it.
  • In other words, it determines how many of the input pages will be included in the output of the operator in the data processing chain.