Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Estimate length of hibernate query

 
rachel parker
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a hibernate query that can take a long time (legitimately I believe, the db is huge). I'd like to display a JProgressBar to the user. Does anyone know how to estimate the time of a hibernate query upfront, and then how to check on the status of the query as it executes? I'd appreciate any help, I'm quite new to hibernate!

Thank you
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you can't really know up front what an ad hoc query is going to return in size, and how long the database will take to retrieve the data, that is outside the call. You can query the table with just a select count(*) from...

With the same from and where clauses to get the number of records. But that still won't tell you how long the databas willt ake to query and return all that data.

So the only thing you can do is have a progress bar that just moves back and forth until all the data is back. Nothing with exact percentages can be done.

However, you might want to look at why you need to return all that data at once, and see if there is a better design that would require a subset of that data at a time.

Hibernate provide paging that can bring say the first 50 records of the query and go to the next 50 an so on.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic