Reputation: 8972
So have a SOLR query in which one of the fq's is a FunctionQuery
See http://wiki.apache.org/solr/FunctionQuery
This is one of my fq's
{!frange l=1}or(and(exists(not(query({!v='type:scu'}))), or(or(termfreq(nba,184887),termfreq(nba,15817823),termfreq(nba,15819703),termfreq(nba,15821195),termfreq(nba,15859845),termfreq(nba,15860041), ...and 2000 other termfreq() calls))),exists(query({!v='isn_field:400112'})),exists(query({!v='(type:scu AND (is_svad:(20332 OR 21017 OR 200662 OR 23 OR 2685 OR 653 OR 266035 OR 267 OR 26612 OR 566127 OR 264129 OR 266133)))'})))
My question is, how does the performance of this FunctionQuery compare to if I'm not using a FunctionQuery, eg if instead of having the function or(termfreq(nba, number), termfreq(nba, number))
statements I just do solr query OR (nba:number1 OR nba:number2 OR nba:number3 ...etc)
?
Is there a way to further optimize that FunctionQuery such that it becomes faster?
Upvotes: 1
Views: 800
Reputation: 52792
In general, the less Function Queries you have to invoke, the better. That said, it might not be a performance issue for your particular use case, depending on the number of documents in the index, the query load and profile, and the usage and size of your caches.
Since Solr has a number of caches available (and Lucene has the Field Cache that caches Function Queries), the actual performance hit will vary depending on external factors.
You'll have to do a few profiling runs or live load testing to tell if it's worth optimising in this case, but remember that fq=-terms are cached separately, so if you re-use parts of the filter queries you can get better cache performance (instead of combining static and dynamic queries in the same filter, split them into one dynamic and one static, so that the static filter can be reused more often). Again, performance will be dependent.
Upvotes: 2