Hello everybody,
I use hibernate 3.3.2 on a MSSQL server and I encounter problems while executing a select statement on the same host to different databases. While it works fine for the first database (<5) it takes more than 10 minutes on the other one. During debugging sessions I noticed that hibernate takes all the time at the preparing statement task. That is the debug log :
Code:
08:43:02,121 DEBUG [SessionImpl] (http-8080-4): opened session at timestamp: 13044985819
08:43:02,133 DEBUG [JDBCTransaction] (http-8080-4): begin
08:43:02,133 DEBUG [ConnectionManager] (http-8080-4): opening JDBC connection
08:43:02,133 DEBUG [JDBCTransaction] (http-8080-4): current autocommit status: true
08:43:02,133 DEBUG [JDBCTransaction] (http-8080-4): disabling autocommit
08:43:02,139 TRACE [JDBCContext] (http-8080-4): after transaction begin
08:43:02,161 TRACE [QueryPlanCache] (http-8080-4): located HQL query plan in cache (SELECT DISTINCT ……)
08:43:02,174 TRACE [QueryParameters] (http-8080-4): named parameters: {1=101}
08:43:02,176 DEBUG [AbstractBatcher] (http-8080-4): about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
08:43:02,192 DEBUG [SQL] (http-8080-4): SQL ……
08:43:02,192 TRACE [AbstractBatcher] (http-8080-4): preparing statement
08:52:08,739 DEBUG [AbstractBatcher] (http-8080-4): about to open ResultSet (open ResultSets: 0, globally: 0)
08:52:08,741 TRACE [Loader] (http-8080-4): processing result set
08:52:08,744 DEBUG [Loader] (http-8080-4): result set row: 0
First I thought the database has problems with indexes or something like that, because the query contains many joins to other tables. But if I copy/paste the SQL result into SQL Server Management Studio and execute it, the result is nearly the same on both databases (execution time and result size are comparable). So there must be any problem at the “preparing statement” phase, but I don’t have any idea what can go wrong at this phase. I don't think it has anything to do with the parsing process of the result, because the result set is the same.
Is the SQL query executed at the “preparing statement” phase or is this done afterwards?
Was there anybody faced with the same problem and was able to solve it or are there any suggestions, what problems there might be?
King regards
Rainer Steinegger