Logical vs Physical Plans
A database describes a query at two levels. The logical plan says what to compute, and the physical plan says how to compute it. Keeping these separate lets the optimizer reason cleanly before committing to machinery.
The logical plan
A logical plan is a tree of relational operators such as filter, project, and join. It expresses the meaning of the query without saying which algorithm to use. A logical join just means combine matching rows.
The physical plan
A physical plan picks a concrete strategy for each logical operator. A logical join might become a hash join or a nested loop join. A logical scan might become a full table scan or an index scan.
- The logical plan is algorithm free and easy to rewrite.
- The physical plan chooses real operators and access methods.
- One logical plan maps to many possible physical plans.
Key idea
The logical plan captures the meaning of a query while the physical plan chooses the concrete algorithms, and the optimizer bridges the two.