simonC
simonC

Reputation: 4327

hibernate query much slower than native query on db

I have a Mysql db an a simple query and I noticed a difference in a query time when executing the query trough the hibernate query editor in Eclipse and executing the same query directly in mysql, the table has 60524 entries(rows)

The hibernate query is

from AppLog a

and it takes 3,4 second

hibernate constructs the native sql like this

select
  applog0_.ID_APP_LOG as ID1_706_,
  applog0_.ID_APP_MODULE_EVENT as ID5_706_,
  applog0_.DATE_INSERT as DATE2_706_,
  applog0_.DESCRIPTION as DESCRIPT3_706_,
  applog0_.ID_PERSON as ID6_706_,
  applog0_.VERSION as VERSION706_ 
 from
  APP_LOG applog0_

when I run this directly on mysql it takes 139 miliseconds

The difference is enormous ... where is the trick?

Upvotes: 3

Views: 974

Answers (1)

Puggan Se
Puggan Se

Reputation: 5846

my guess is that reading the data takes the same amount of time, and displaying it in the mysql prompt, takes almost no time at all, but coping 60k rows from mysql to Eclipse takes longer time, and proberly responible for the extra 3.3 secounds. whit mysql profiling you can dig a bit deeper in where the times go, http://dev.mysql.com/doc/refman/5.0/en/show-profiles.html

Upvotes: 5

Related Questions