{
  "schema_version": 2,
  "id": "commands/cms.initbydim",
  "title": "CMS.INITBYDIM",
  "url": "https://redis.io/docs/latest/commands/cms.initbydim/",
  "summary": "Initializes a Count-Min Sketch to dimensions specified by user",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:54+01:00",
  "page_type": "content",
  "content_hash": "38dbdb8691907f041765ec578942afb1a635451d466307c05ed089f77b86f226",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Initializes a Count-Min Sketch to dimensions specified by user."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the sketch.\n\n</details>\n\n<details open><summary><code>width</code></summary>\n\nNumber of counters in each array. Reduces the error size.\n\n</details>\n\n<details open><summary><code>depth</code></summary>\n\nNumber of counter-arrays. Reduces the probability for an error of a certain size (percentage of total count).\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "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](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings) `OK` if executed correctly.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) if the given key already exists.\n\n**RESP3:**\n\nOne of the following:\n\n* [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings) `OK` if executed correctly.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) if the given key already exists."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> CMS.INITBYDIM test 2000 5\nOK",
      "section_id": "examples"
    }
  ]
}
