Conceptual
Login

What a Prepared Statement's Parameter Is, and Why the Engine Cannot See Its Value

A parameter is a placeholder in a prepared statement, written $1 or ?, whose value arrives separately when the statement runs. The statement's text never changes, so the same query text serves every value, which is what makes plan reuse possible. The catch is that when the database plans a statement without knowing the value, it has to guess how many rows the condition will keep, and a guess made for an average value can be badly wrong for an unusual one.

Questions this Concept answers

  • Why can a plan chosen without knowing a parameter's value be badly wrong for some values?