content/commands/tdigest.merge.md
{{< 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.
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.
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.
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:
destination-key does not exist or if OVERRIDE is specified, the compression is set to the maximum value among all source sketches.destination-key already exists and OVERRIDE is not specified, its compression is not changed.If destination-key already exists and OVERRIDE is specified, the key is overwritten.
{{< 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
| 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> | |
{{< multitabs id="tdigest-merge-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
OK if successful.-tab-sep-
One of the following:
OK if successful.{{< /multitabs >}}