PreparedStatement, it is said offers better performance that Statement object by virtue of being "pre-compiled". When the above pre-compilation takes place, the SQL query is fine-tuned for various aspects, one among which is performance - this ofcourse, is based on the current size/contents of the table. What if the table size is so large, and the PreparedStatement is used for a large number of operations - wont the query optimization be wrong in that case ?Rather, wont this wrong optimization affect the performance in the long run ?
Joined: Jul 13, 2004
Awaiting a response for this.
Peter den Haan
Joined: Apr 20, 2000
An execution plan can become less appropriate as the volume or composition of the data changes, but it's up to the database and/or its JDBC driver to decide how long to cache a plan for. You would hope that there is some invalidation mechanism, even if it is only a maximum age.
Joined: May 03, 2004
Prepared Statements by virtue are reusable statements rather creating a new statement every time . as the normal Statement does...
As u said Prepared Statements does not do or write any performance tuning internally....
For performance reasons mean for using the same statement repeatedly we use Prepared Statement for example insert statement ...