1) Query optimization by the database. This also happens in case of a PreparedStatement, but because it uses bind variables, optimization can be more limited. In practice the cost of recompilation usually outweighs the performance gained by further optimizing the query.
2) The database prepares and caches the execution plan of the SQL query that results from the PreparedStatement.
3) The database runs the execution plan.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.