• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

precompilation of PreparedStatements

 
Pushker Chaubey
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do we mean by precompiled nature of preparedstatements? where are these statements complied and stored?
 
Joice Jose
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PreparedStatement is more efficient than Statement object if you are executing similar statements multiple times. When a PreparedStatement is created, the SQL statement is sent to the database for precompilation. The precompiled form of a prepared statement is cached only as long as the PreparedStatement instance is alive, so the performance benefits are only obtained when reusing the same PreparedStatement instance, setting different parameters on each invocation.
 
Joice Jose
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this
 
Chris Hendy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This depends on the database.

Oracle for instance will cache parsed SQL and execution plans in its own shared memory area. They will stay there even if the session that first submitted it drops the connection, unless and until they are aged out by more recently requested statements needing the space.
[ December 12, 2006: Message edited by: Chris Hendy ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic