1

I can see that cts.values and cts.elementValues has similar use.

In that case, what is the difference between both of them in terms of performance? Which is more efficient?

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Manish
  • 59
  • 3

1 Answers1

4

They should perform the same. Both of those functions provide a way to query lexicons (range indexes).

With cts.values(), the first parameter is a cts.reference[]. So, that means that you can provide any of the cts.reference types: cts.elementReference, cts.elementAttributeReference, cts.fieldReference, cts.jsonPropertyReference, cts.pathReference, as well as cts.collectionReference and cts.uriReference.

With the cts.elementValues() query, the first parameter is an xs.QName[] for the element(s), rather than a cts.reference[].

These other lexicon values functions have a similar difference in the parameters, but are also effectively a different way of invoking cts.values():

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • 1
    Minor addition: the more specific `cts.elementValues` e.a are the original function names. Over time more and more index types were added, and at some point it made sense to provide a more generic `cts.values` that takes references instead. Similar story for `cts.elementRangeQuery` vs `cts.rangeQuery`. Around the same time `cts.valueTuples` was added as well if I am not mistaken, that allows a random combination of references to be passed in, as opposed to the much more rigid `cts.elementValueCoOccurrences` e.a.. – grtjn Feb 26 '20 at 12:37