Detailed comparisson between TRO and TCO

Can anyone give at least 5 detailed examples of queries of TRO and TCO because I’m worried about for what queries I’m going to be billed for and can understand when do I need or not each type of query in my coding.

Hi @Lester_Vargas

What do you mean by “each type” of query?

A “TRO” query and a “TCO” query? I don’t know if it’s appropriate to describe queries as simply one or the other. You could easily construct a query that costs a bunch of both, or maybe a little of both.

The docs billing page would be the best description of what operations incur Transactional Read Ops and Transactional Compute ops. But that doesn’t necessarily give you an instinct of what a query will cost.

TCO notes

Compute ops are actually one of the easiest things to predict. Every 50 function call = 1 TCO. That’s it! This can be tested in the web shell.

Map(                               // 1 function call
  [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10
  Lambda(                         // 0 calls?  I think Lambda is transparent
    Add(Var('n'), 100)            // 2 function calls per mapped item

// 1 + 25 * 2 = 51 = 2 TCOs

This example shows that if you Map over a Page of results to Get the Documents, for example, it will take 1 TCO for every 25 Documents.

TRO notes

There’s a bunch of rules that the docs specify for reads. I won’t repeat the docs, but here’s some things that might help.

experiment and observe your queries

Remember that the “x-byte-read-ops” is the “Transactional Read Ops”. It’s there in the docs, but I was confused for a while, myself :slight_smile: so don’t make the same mistake! This can be seen in the shell, or observe the headers in your favorite driver. It helps now that “readOps” no longer shows up along with “byteReadOps” :laughing:


TRO per Index partition

From docs: “Additionally, one read operation per index partition is counted. An index with no terms defined has 8 partitions.”. Also from Create Index docs, the number of partitions is

  • 1 when unique is true.
  • 8 when the index has no terms.
  • 1 in all other cases.

Set Operations

Different Set operations cost different amounts, base on how much they have to read its arguments.

For example Union should be about 1 TRO per Set argument. Intersection works out closer to 2 * [# of Set arguments].

If you build queries that uses Union, Intersection, Difference, etc. or especially various combinations of them, I recomend need to experiment. If there are multiple indexes used, each index might cost different amounts depending on the size or the partitions, and that all adds up in different ways.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.