On 17/05/12 3:47am, Joe Baldwin wrote:
This is an follow-up to a question I asked previously.
**** To re-cap
In the context of a web-app (i.e. you don't know who your users are, or what
kind of absurd 'give me everything and let me sort' actions they might take), I
need to be able to support real-time sorting of perhaps large result sets.
So the recommendation was to prefer the DBMS sort over Cayenne in-memory sort
(which would fault all of the result-set dataobjects). I can sort of
understand the rational that it is better to re-submit the query with a new
sort-by request, as this will ultimately be more memory efficient.
Requirements
Also, I have some fairly advanced pre-built search methods that support
often-used searches. It is the results of these searches that may be sorted
several times and in several different ways by the user.
**** Interesting Side-effect
In order to implement the 'let the DBMS do it' pattern, I created a
SearchFactory class that stores the pre-built Cayenne SelectQuery, so that I
can resubmit it to Cayenne with a user chosen sort-by specification. Here are
some questions:
1. I have to store the SelectQuery in a custom session object. This *seems*
like a good idea but since I have never done this, I was wondering if storing a
query might not be memory-efficient. i.e. does this object hold on to any
result sets?
Not to my knowledge, no.
2. This pattern essentially makes some of the very cool Cayenne ORM features
useless. i.e. I can no longer simply request the Vendor's associated product
list by doing a Cayenne 'vendor.getProductList()', since I can't store the
query (as I need to do in order to re-submit the query with a new Ordering
object).
I am not clear why you can no longer use these getters. Don't you just take
your query and add whatever ordering you want before submitting it?
This is all working, but since I have to make a *lot* of changes in my code, I
want to make sure it is the best solution with Cayenne.
Does all of this sound reasonable, or am I missing some simpler way of
implementing this solution?
What problem are you trying to solve? Where are you hitting performance issues?
On the first query? On subsequent queries with changed orderings?
Are you using Cayenne's pagination feature (that can make a huge performance
improvement)?
Are you using OSCache?
Have you thought about using Solr/Lucene? For complex queries and orderings it
has fantastic performance, but this really only works for public websites where
all users see the same data.
Cheers
Ari
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A