-->
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.  [ 3 posts ] 
Author Message
 Post subject: query.setParameter Slows my MSSQL server query
PostPosted: Wed Jun 11, 2008 7:56 am 
Newbie

Joined: Wed Jun 11, 2008 7:51 am
Posts: 8
Hello, i'm using SQL-Server with a 3 million record table. Everytime i use setParameter instead of an ordinary string it slows down from 75ms to 40s.
I have been doing some more digging and it seems that setParameter creates a prepared statement, that is to say a precompiled query which is supposed to slow down the first time its executed but faster if it is executed later on in the same connection.
The things is that i prefer to use a statement instead of a prepared statement but How can I use HQL and setParameter to create statements instead of prepared statements?

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 2:13 pm 
Newbie

Joined: Wed Jun 11, 2008 7:51 am
Posts: 8
problem solved!!
It had nothing to do with hibernate. MS SQL Server 2005 doesn't use prepared statements by default. All i had to do was to create a new database with the options->parametrized->forced and it worked fine.
I hope this helps somebody else!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 4:48 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
forced?

I've seen this very problem posted in a few places. It's nice to finally have a solution!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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

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.