{
  "id": "tdigest.merge",
  "title": "TDIGEST.MERGE",
  "url": "https://redis.io/docs/latest/commands/tdigest.merge/",
  "summary": "Merges multiple t-digest sketches into a single sketch",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-04-09T10:29:34-04:00",
  "page_type": "content",
  "content_hash": "46cbb38e057cd86bfb01fe7a4c2c176a4df042678d607d83b5739fc43512024b",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command's behavior varies in clustered Redis environments. See the [multi-key operations]() page for more information.\n\n\n\nMerges multiple t-digest sketches into a single sketch."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>destination-key</code></summary>\n\nis the key name for a t-digest sketch to merge observation values to.\n\nIf `destination-key` does not exist, a new sketch is created.\n\nIf `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`.\n</details>\n\n<details open><summary><code>numkeys</code></summary>\n\nthe number of sketches from which to merge observation values (one or more).\n</details>\n\n<details open><summary><code>source-key</code></summary>\n\nEach `source-key` is a key name for a t-digest sketch from which to merge observation values.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>COMPRESSION compression</code></summary>\n  \nis 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_](https://www.sciencedirect.com/science/article/pii/S2665963820300403).\n  \nWhen `COMPRESSION` is not specified:\n- If `destination-key` does not exist or if `OVERRIDE` is specified, the compression is set to the maximum value among all source sketches.\n- If `destination-key` already exists and `OVERRIDE` is not specified, its compression is not changed.\n\n</details>\n\n<details open><summary><code>OVERRIDE</code></summary>\n\nIf `destination-key` already exists and `OVERRIDE` is specified, the key is overwritten.\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> TDIGEST.CREATE {metrics}:m1\nOK\nredis> TDIGEST.CREATE {metrics}:m2\nOK\nredis> TDIGEST.ADD {metrics}:m1 10.0 20.0\nOK\nredis> TDIGEST.ADD {metrics}:m2 30.0 40.0\nOK\nredis> TDIGEST.MERGE {metrics}:m 2 {metrics}:m1 {metrics}:m2\nOK\nredis> TDIGEST.BYRANK {metrics}:m 0 1 2 3 4\n1) \"10\"\n2) \"20\"\n3) \"30\"\n4) \"40\"\n5) \"inf\""
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Supported</span><br /> | <span title=\"Supported\">&#x2705; Flexible & Annual</span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n\n* [Simple string reply]() `OK` if successful.\n* [Simple error reply]() in the following cases: incorrect key type, incorrect keyword, or incorrect number of arguments.\n\n**RESP3:**\n\nOne of the following:\n\n* [Simple string reply]() `OK` if successful.\n* [Simple error reply]() in the following cases: incorrect key type, incorrect keyword, or incorrect number of arguments."
    }
  ],
  "examples": []
}
