[MarkLogic Dev General] Query performance: getting all documents in a collection

Dominic Mitchell dom at semantico.com
Thu Aug 23 07:19:31 PDT 2007


Mattio Valentino wrote:
> Here's the query:
> 
> for $i in cts:search(//book, cts:collection-query('testcol'))
> return
>   <result id=" { $i/@local-id } " />
> 
> I'm trying to return what will eventually be a title list.  The root
> node of all the documents in the collection is "book" and I'd like to
> return them all.  There are only 150 documents now, but there will be
> around 300.  The query is taking about 20 seconds to run and utilizes
> about 30% of the CPU.
> 
> What can I do to improve this query?

If book is the root element, then saying "/book" instead of "//book" 
should perform better.

If I understand that correctly, though, can't you just say:

   for $book in collection('testcol')/book
   return <result id="{ $book/@local-id }" />

-Dom


More information about the General mailing list