-->
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: saving IDs of queried objects in a LRU cache for pagination
PostPosted: Wed May 09, 2007 2:43 pm 
Newbie

Joined: Tue Mar 27, 2007 12:42 pm
Posts: 5
Hi,
i have a query which does need quite a bit of time (5 secs - up to 1000 items) and i want to improve the performace for pagination.

So i thought about fire this query just one time, and then save the IDs of this query in a Least Recently Used cache (LRU) with the query object as the key.

Now, if the same query is needed ( User wants the next page or re-orders the result ) i first check if this query is in the cache.
If true, i take the list of IDs and make a WHERE .. FROM .. IN query:

List result = session
.createQuery("FROM .. WHERE .. IN (" + cache.getIdStringList(query) + ")")
.setFirstResult(from)
.setMaxResults(max)
.list();


My question:
- does this approach maybe overrides a hibernate built in caching
- does this approach scale if if have more results than 1000 ( i think theres a limit of the number of WHRERE IN ( .. ) items)

or

how are you handling pagination for complex queries ?
i think the constraints .setFirstResult(from) .setMaxResults(max) do have no affect on the speed of the query or am i wrong with that ?


thanx for any hints,
chris


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.