-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Query takes very long on different databases with same setup
PostPosted: Thu May 05, 2011 3:49 am 
Newbie

Joined: Wed May 04, 2011 10:59 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.