Hi As we all know, there's no COUNT feature in SQL2. This is not that bad, if you're not trying to get a count via remoting, since you can get it with .getSize() locally. But if you're working via the webdav layer, it's not really efficient right now, especially if your resultsets are larger.
There are in my opinion 2 opinions to solve this. 1) add a count() feature to the SQL2 parser, there's already a ticket for that (among other things) https://issues.apache.org/jira/browse/JCR-2605 That of course would be a great solutions, it solves the problem for all cases who need that 2) add an option to the SEARCH webdav interface to get the count if results instead of the whole result set. For 2) I made a little prototype (which is really just that ;)) to see if that would be feasible. That patch can be found here https://github.com/chregu/jackrabbit/compare/count-in-webdav It adds a D:count option to a SEARCH query like this <D:searchrequest xmlns:D="DAV:"> <JCR-SQL2> <![CDATA[SELECT * FROM [nt:unstructured] ]]> </JCR-SQL2> <D:count>1</D:count> </D:searchrequest> and if that is set it returns only the count of results. Currently like below, but that format has certainly to be changed (it was just the shortest way to get something back): <D:multistatus xmlns:D="DAV:"> <D:response> <D:href>#count</D:href> <D:responsedescription>433</D:responsedescription> </D:response> <D:responsedescription>nt:unstructured.jcr:primaryType</D:responsedescription> </D:multistatus> My questions: - Is there any chance that something like this goes into jackrabbit and we can build on that feature? - Or is there a better way to just get the count of a query? - How should the response look like for something like this? The above is certainly not right ;) - And last but not least, are there any plans to implement COUNT() some time in the future directly in SQL2? Thanks for any feedback. chregu
