Optic API 与 CTS 查询性能
Optic API vs CTS query performance
我正在使用以下两个查询(Optic and CTS)
来获取路径范围索引的值 /tXML/Item/PutawayCategory
。
查询 1: - 大约花费了4 milliseconds
执行和 return 17 个不同的值。我尝试多次执行同一个查询。
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
op:from-lexicons(map:entry("PutawayCategory", cts:path-reference("/tXML/Item/PutawayCategory")))
=> op:where-distinct()
=> op:result()
查询 2: - 大约花费了0.30 milliseconds
得到与 Query 1
相同的结果
xquery version "1.0-ml";
cts:values(cts:path-reference("/tXML/Item/PutawayCategory"))
我不明白为什么 Optic Query
比 cts
查询花费更多的时间来执行。
请帮助我理解这一点。
将您的光学查询更改为使用 op:group-by("PutawayCategory")
而不是 op:where-distinct()
,它的性能应该会好得多。
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
op:from-lexicons(map:entry("PutawayCategory", cts:path-reference("/tXML/Item/PutawayCategory")))
=> op:group-by("PutawayCategory")
=> op:result()
与op:from-lexicon
Optic emits rows based on co-occurrence of lexicon values within the same document similar to cts:value-tuples
.
这意味着 op:from-lexicons()
正在返回多个文档中存在的值的每个实例,并且可以多次返回,而不是一个不同的列表,然后 op:where-distinct()
正在过滤和删除-复制,这会消耗 CPU 和时间。值集越大,op:where-distinct()
要做的工作(和时间)就越多。
cts:values()
直接从路径范围索引词典中提取不同的值列表,因此需要做的工作更少。
MarkLogic 可能有一种方法可以使用 op:where-distinct()
优化 Optic 查询。如果您有权访问 MarkLogic 支持,创建一个支持案例来查询它将会很有帮助。
我正在使用以下两个查询(Optic and CTS)
来获取路径范围索引的值 /tXML/Item/PutawayCategory
。
查询 1: - 大约花费了4 milliseconds
执行和 return 17 个不同的值。我尝试多次执行同一个查询。
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
op:from-lexicons(map:entry("PutawayCategory", cts:path-reference("/tXML/Item/PutawayCategory")))
=> op:where-distinct()
=> op:result()
查询 2: - 大约花费了0.30 milliseconds
得到与 Query 1
xquery version "1.0-ml";
cts:values(cts:path-reference("/tXML/Item/PutawayCategory"))
我不明白为什么 Optic Query
比 cts
查询花费更多的时间来执行。
请帮助我理解这一点。
将您的光学查询更改为使用 op:group-by("PutawayCategory")
而不是 op:where-distinct()
,它的性能应该会好得多。
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
op:from-lexicons(map:entry("PutawayCategory", cts:path-reference("/tXML/Item/PutawayCategory")))
=> op:group-by("PutawayCategory")
=> op:result()
与op:from-lexicon
Optic emits rows based on co-occurrence of lexicon values within the same document similar to
cts:value-tuples
.
这意味着 op:from-lexicons()
正在返回多个文档中存在的值的每个实例,并且可以多次返回,而不是一个不同的列表,然后 op:where-distinct()
正在过滤和删除-复制,这会消耗 CPU 和时间。值集越大,op:where-distinct()
要做的工作(和时间)就越多。
cts:values()
直接从路径范围索引词典中提取不同的值列表,因此需要做的工作更少。
MarkLogic 可能有一种方法可以使用 op:where-distinct()
优化 Optic 查询。如果您有权访问 MarkLogic 支持,创建一个支持案例来查询它将会很有帮助。