[MarkLogic Dev General] Struggling with Query Time Out

David Lee David.Lee at marklogic.com
Fri Mar 16 11:53:32 PDT 2012

First off cts:search is exactly what you want for this. 
Second you are doing string compares against datetime values.  To help with this you may need to create a range index  on EventDate and compare against xs:dateTime('xxxxxx')
Thirdly your doing a directory search which you might not actually need if these documents are in know namespaces. 
But hold off on that until you get the first two worked out. 
cts:search() is really your friend in this case, but you do want to make a range index so that the system knows the values are dates otherwise "gt" will do string not date comparisons

Once you get both those working your searches should be nearly instant.

David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 650-287-2531
Cell:  +1 812-630-7622

This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation.

> -----Original Message-----
> From: general-bounces at developer.marklogic.com [mailto:general-
> bounces at developer.marklogic.com] On Behalf Of Betty Harvey
> Sent: Friday, March 16, 2012 3:17 PM
> To: MarkLogic Developer Discussion
> Subject: [MarkLogic Dev General] Struggling with Query Time Out
> I have been unable to get this query to run successfully without timing
> out.  To make sure my logic was correct I placed 100 documents in the
> 'documents' database and query runs successfully and very quickly. In the
> large database 1.7 million objects the query always times out.
> I am not sure cts:search will help.  I played around with it without
> success.   The goal of the query is to gather information for a particular
> month based on when the document was created.   Below is the code:
> for $ACE in xdmp:directory('opt/MOR/ACE/')/descendant::ACE
>    [EventSet/GeneralEvent[1]/EventDate gt '2011-03-01T00:00:00']
>    [EventSet/era:GeneralEvent[1]/EventDate lt '2011-04-01T00:00:00']
> let $ACEId := $ACE/ACEId
> let $EventDate := $ACE/EventSet/era:GeneralEvent[1]/era:EventDate
> return
> <a>
> {$ACEId}
> {$EventDate}
> </a>
> Any ideas are appreciated!
> Betty
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general

More information about the General mailing list