Question

We are using Ibatis in our project. When the query executes the first time it's slow. But afterwards, the same set of queries are a bit faster than the first time. So are the queries being compiled the first time they execute?

Was it helpful?

Solution

iBbatis like any database framework built over JDBC, uses PreparedStatement to execute SQL queries. From the Java JDBC tutorial

The advantage to this is that in most cases, this SQL statement is sent to the DBMS right away, where it is compiled. As a result, the PreparedStatement object contains not just a SQL statement, but a SQL statement that has been precompiled.

So, if by precompiled, you meant on the database, then, yes, they are.

OTHER TIPS

I will like to add that the compilation phase is one of the main phases of an SQL query execution flow. It just gets compiled and cached once by your db optimizer and subsequent calls will skip the compilation phase.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top