what approach should I take in heavy iterations? [closed]
开发者_Go百科
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this questionI got this Java webapp (JSP+Struts+Hibernate+MySQL+tomcat6) in which there are like 20000 users right now and the number is growing up rapidly. I have to rank all the users periodically. The ranking process involves lots of objects and hibernate actions and it's fairly heavy. Talking java, unfortunately I must iterate on all of the users and apply this procedure in them one by one. this method sucks out lots of the server's resources.
on the other hand I might be able to run all these actions in a stored procedure on the MySQL side. I'm pretty sure the code there will be a complete mess and troublesome to modify later on. although the performance would be much more better this way but software engineering principles wouldn't take this solution nicely.
what do you suggest?
This is obviously much more efficient in SQL. The real problem is that you are using hibernate and so have lost control over your schema which is why a solution like iBatis, although less popular, makes more sense - because it allows you to switch to SQL when that is the more appropriate tool for the job.
Given that you have chosen hibernate, are you sure that you can't push the API it provides into doing this? Have you looked in detail at the criteria API? That includes associations - it might be possible to shoe-horn what you want in there and so keep the logic more closely associated with the classes. http://docs.jboss.org/hibernate/stable/core/reference/en-US/html/querycriteria.html
精彩评论