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

Mattio Valentino mattio.valentino at gmail.com
Thu Aug 23 09:33:56 PDT 2007


Amazing.  That performs much faster, which is what I expected.

Thanks for your help, Dominic.  I didn't even think to look through
the standard set of functions.

On 8/23/07, Dominic Mitchell <dom at semantico.com> wrote:
> 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 }" />


More information about the General mailing list