Saturday, May 31, 2008

Why Prepared Statements are faster? Are they compiled?


Question: Why Prepared Statements are faster? Are they compiled?


Answers: Prepared Statements are faster not because they are compiled (in fact they are not compiled), instead the reason for them being faster is that they are bound to the underlying JDBC Driver. Whenever you create a prepared statement, all the columns involved in that SQL statement get bound to the JDBc driver and hence the binding overhead gets eliminated while execution which in turn makes the prepared statements faster. We use Connection.prepareStatement() to create a prepared statement.



Share/Save/Bookmark


No comments: