Preparing statements

Each time a statement is sent to a database, the database server must perform the following steps:

  • It must parse the statement and transform it into an internal form. This is sometimes called preparing the statement.

  • It must verify the correctness of all references to database objects by checking, for example, that columns named in a query actually exist.

  • The query optimizer generates an access plan if the statement involves joins or subqueries.

  • It executes the statement after all these steps have been carried out.

 Reusing prepared statements can improve performance
 Do not prepare statements that are used only once

How to use prepared statements