-->
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: Are Parameterized query SLOWER?
PostPosted: Thu Sep 16, 2004 9:00 am 
Newbie

Joined: Wed Mar 03, 2004 5:54 pm
Posts: 3
I've found a very strange problem in my code using Hibernate.
Parameterized query runs slower than a "plain" one.

For example I write:
Code:
            String sQuery =
                   "SELECT {gn.*} FROM geo_name as {gn} " +
                  "WHERE {gn}.id >= 279641 AND {gn}.id < 279741 ";
            Query query = session.createSQLQuery( sQuery, "gn", GeoName.class );
            List result =  query.list();


I takes only 132 ms. Good!


But If I use parameter in query

Code:
            String sQuery =
                   "SELECT {gn.*} FROM geo_name as {gn} " +
                  "WHERE {gn}.id >= :id_fr AND {gn}.id < :id_to ";
            Query query = session.createSQLQuery( sQuery, "gn", GeoName.class );
            query.setInteger( "id_fr", 279641 );
            query.setInteger( "id_to", 279741 );
            return query.list();


The query takes 610 ms. Four times slower !!

This very strange and happens always. Have nobody experienced the same?
Any idea to solve it.

Thanks in advance for any idea or suggestion.
Paolo


Hibernate version: 2.1.6

Name and version of the database you are using: Sybase 12.5


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.