Back to Redis

TDIGEST.MERGE

content/commands/tdigest.merge.md

latest3.4 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

Merges multiple t-digest sketches into a single sketch.

Required arguments

<details open><summary><code>destination-key</code></summary>

is the key name for a t-digest sketch to merge observation values to.

If destination-key does not exist, a new sketch is created.

If destination-key is an existing sketch, its values are merged with the values of the source keys. To override the destination key contents use OVERRIDE.

</details> <details open><summary><code>numkeys</code></summary>

the number of sketches from which to merge observation values (one or more).

</details> <details open><summary><code>source-key</code></summary>

Each source-key is a key name for a t-digest sketch from which to merge observation values.

</details>

Optional arguments

<details open><summary><code>COMPRESSION compression</code></summary>

is a controllable tradeoff between accuracy and memory consumption. 100 is a common value for normal uses and also the default if not specified. 1000 is more accurate. For more information on scaling of accuracy versus the compression value see The t-digest: Efficient estimates of distributions.

When COMPRESSION is not specified:

  • If destination-key does not exist or if OVERRIDE is specified, the compression is set to the maximum value among all source sketches.
  • If destination-key already exists and OVERRIDE is not specified, its compression is not changed.
</details> <details open><summary><code>OVERRIDE</code></summary>

If destination-key already exists and OVERRIDE is specified, the key is overwritten.

</details>

Examples

{{< highlight bash >}} redis> TDIGEST.CREATE {metrics}:m1 OK redis> TDIGEST.CREATE {metrics}:m2 OK redis> TDIGEST.ADD {metrics}:m1 10.0 20.0 OK redis> TDIGEST.ADD {metrics}:m2 30.0 40.0 OK redis> TDIGEST.MERGE {metrics}:m 2 {metrics}:m1 {metrics}:m2 OK redis> TDIGEST.BYRANK {metrics}:m 0 1 2 3 4

  1. "10"
  2. "20"
  3. "30"
  4. "40"
  5. "inf" {{< / highlight >}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |

Return information

{{< multitabs id="tdigest-merge-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) OK if successful.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in the following cases: incorrect key type, incorrect keyword, or incorrect number of arguments.

-tab-sep-

One of the following:

  • [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}) OK if successful.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in the following cases: incorrect key type, incorrect keyword, or incorrect number of arguments.

{{< /multitabs >}}