# About the optimizer's choice of access path

The optimizer's choice of access path can depend on the number of rows it will have to read. It tries to choose a path that requires the fewest number of rows read.

For joins, the number of rows read also depends heavily on the join order (discussed in About the optimizer's choice of join order.)

How does the optimizer know how many rows a particular access path will read? Sometimes it knows exactly, and sometimes it has to make an educated guess. See Selectivity and cardinality statistics.

Parent topic: Derby's cost-based optimization
Related concepts
About the optimizer's choice of join order
About the optimizer's choice of join strategy
About the optimizer's choice of sort avoidance
About the system's selection of lock granularity
About the optimizer's selection of bulk fetch