简体   繁体   English

如何在 Marklogic 中使用 Xquery 从数百万条记录中获取 CustomerId

[英]How to get CustomerId from millions of records using Xquery in Marklogic

We have a large database, and I am supposed to get only CustomerId's from the entire database without compromising the performance.我们有一个大型数据库,我应该只从整个数据库中获取 CustomerId,而不会影响性能。 What is the best way to do it?最好的方法是什么?

If you are looking to report all of the CustomerId values from a large database, then having some sort of backing index will be the fastest and most efficient.如果您希望报告大型数据库中的所有CustomerId值,那么拥有某种支持索引将是最快和最有效的。 With an index, retrieving the distinct list of values from a lexicon with a functions such as:使用索引,从具有以下功能的词典中检索不同的值列表:

  • cts:values() eg cts:values(cts:element-reference('CustomerId')) or cts:values(cts:path-reference('/Customer/CustomerId')) cts:values()例如cts:values(cts:element-reference('CustomerId'))cts:values(cts:path-reference('/Customer/CustomerId'))
  • cts:element-values() eg cts:element-values(xs:QName("CustomerId")) cts:element-values()例如cts:element-values(xs:QName("CustomerId"))

You could also create a TDE that has a CustomerId field and retrieve the values with an Optic query.您还可以创建一个具有CustomerId字段的TDE ,并使用光学查询检索这些值。

If you wanted to report the values without creating an index, then you could create a CoRB batch job to select the docs that have that element, return the value(s) from the process module, and write the values to an output file apply the EXPORT-FILE-SORT=ascending|distinct option.如果您想在不创建索引的情况下报告值,那么您可以创建一个 CoRB 批处理作业到 select 具有该元素的文档,从流程模块返回值,并将值写入 output 文件应用EXPORT-FILE-SORT=ascending|distinct选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM