Discussion:
[MarkLogic Dev General] fn:collection vs cts:collection-query
K***@cognizant.com
2013-10-09 09:58:48 UTC
Permalink
Assume that I have a cts:search query which finds list of documents in a particular collection.
Is it better to use fn:collection or cts:collection-query for filtering based on collection.

For ex:
Should I use cts:search(/test,cts:collection-query("test-docs")) or cts:search(fn:collection("test-docs")/test)

Which query will perform better if we have millions of documents starting with /test that can be present in different collections?

Thanks,
Karthik

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
Geert Josten
2013-10-09 10:16:55 UTC
Permalink
Hi Karthik,



You could argue that starting with a smaller set (second expression) would
be more efficient, but that involves a search as well, so I wouldn’t be
surprised if in the end both expressions do the same thing. To be sure,
just measure the difference with a large test set, making sure caches are
flushed in between..



There might be another reason to pick one above the other: if you are
compiling the search query dynamically, the first expression will be more
convenient..



Cheers,

Geert



*Van:* general-***@developer.marklogic.com [mailto:
general-***@developer.marklogic.com] *Namens *
***@cognizant.com
*Verzonden:* woensdag 9 oktober 2013 11:59
*Aan:* ***@developer.marklogic.com
*Onderwerp:* [MarkLogic Dev General] fn:collection vs cts:collection-query



Assume that I have a cts:search query which finds list of documents in a
particular collection.

Is it better to use fn:collection or cts:collection-query for filtering
based on collection.



For ex:

Should I use cts:search(/test,cts:collection-query(“test-docs”)) or
cts:search(fn:collection(“test-docs”)/test)



Which query will perform better if we have millions of documents starting
with /test that can be present in different collections?



Thanks,

Karthik



This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. If you are not the intended recipient(s), please reply to the
sender and destroy all copies of the original message. Any unauthorized
review, use, disclosure, dissemination, forwarding, printing or copying of
this email, and/or any action taken in reliance on the contents of this
e-mail is strictly prohibited and may be unlawful.

Loading...