This document discusses cost-based optimization and statistics in Firebird. It covers: 1) Rule-based optimization uses heuristics while cost-based optimization uses statistical data to estimate the cost of different access paths and choose the most efficient. 2) Statistics like selectivity, cardinality, and histograms help estimate costs by providing information on data distribution and amounts. 3) The optimizer aggregates costs from the bottom up and chooses the access path with the lowest total cost based on the statistical information.