-->
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.  [ 2 posts ] 
Author Message
 Post subject: Slow NHibernate query
PostPosted: Wed Oct 12, 2011 8:47 am 
Newbie

Joined: Wed Oct 12, 2011 8:42 am
Posts: 2
Hi,

I'm executing a query against a Sybase database server and execution times are very slow in some cases.

Here are the execution times for the NHibernate query methods that I have tested:
- HQL with SetParameter() : 7 seconds (KO)
- native SQL : 23 ms (OK)
- "native" HQL (no SetParameter()) : 23 ms (OK)
- ICriteria : 7s (KO)

Details:
- NHibernate version is 3.2.0.
- The execution times are the same for both attribute and XML mapping.
- The query is a simple SELECT query, with no join, and only equality comparisons.


Does anybody have any clue ?


Thanks in advance,
Elyes.


Top
 Profile  
 
 Post subject: Re: Slow NHibernate query [Problem solved]
PostPosted: Thu Oct 13, 2011 4:54 am 
Newbie

Joined: Wed Oct 12, 2011 8:42 am
Posts: 2
Hi again,

The Sybase DB server is Sybase 12, and we were hitting it with a Sybase 15 driver. Sorry for omitting this important info.

In the Sybase15 dialect, DbType.String is mapped to "nvarchar(255)".
Our properties were mapped to "DbType.String".

We used the IQuery.SetParameter() method and at runtime, that resolved the driver type to AseType.Univarchar (a Sybase15 data type), which in turn had to be converted from the actual Sybase12 type "varchar".


So as a summary:

  • CLR : System.String
  • NHibernate : DbType.String
  • Sybase15 Dialect : nvarchar(255)
  • Sybase15 Driver : univarchar (for some (weird?) reason)
  • Sybase12 DB server : varchar


Why that takes 7 seconds for a single row is only known of the driver's developers.


Changing the column mapping to DbType.AnsiString solved the problem.


Thanks to the viewers ^^
Elyes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.