Performance of Search Predicates vs SQL2 queries
Hi,
Are there any performance differences between Search Predicates and SQL2 queries in CQ 5.6?
Which one is the recommended API for querying for specific nodes in the CRX?
Thanks.
Hi,
Are there any performance differences between Search Predicates and SQL2 queries in CQ 5.6?
Which one is the recommended API for querying for specific nodes in the CRX?
Thanks.
Short answer: No.
Longer answer: No, since the Search Predicates generates SQL2 queries in the backend there are, in theory, no difference. However, my experience is that developers tend to be better in using Predicates in Java code and get better preformance out of those queries than when they use SQL2 directly. My quess is that this is because the fellows that has been writing the Predicates actually know what they are doing and optimize the queries and most of us does not understand SQL2 well enough to beat them.
I have also noted that in most cases when loops are used to create queries, the actuall creation of the query is faster using Predicates than SQL2 string concatenation. Som my advice is: Use Search Predicates if you can. Use SQL2 queries if they are static and easy to understand.
/Ove
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.