{
    "version": "https://jsonfeed.org/version/1",
    "title": "ClickHouse Knowledge Base Feed",
    "home_page_url": "https://clickhouse.com/docs/knowledgebase",
    "description": "Feed of articles posted to the ClickHouse Knowledge Base",
    "items": [
        {
            "id": "https://clickhouse.com/docs/knowledgebase/terraform_example",
            "content_html": "This covers an example of how you can use terraform to create/delete clusters using the API<!-- -->\n<!-- -->\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"question\">Question<a href=\"https://clickhouse.com/docs/knowledgebase/terraform_example#question\" class=\"hash-link\" aria-label=\"Direct link to Question\" title=\"Direct link to Question\">​</a></h2>\n<p>How can I use API to manage clusters on ClickHouse Cloud?</p>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"answer\">Answer<a href=\"https://clickhouse.com/docs/knowledgebase/terraform_example#answer\" class=\"hash-link\" aria-label=\"Direct link to Answer\" title=\"Direct link to Answer\">​</a></h2>\n<p>We will use Terraform to configure our infra and <a href=\"https://registry.terraform.io/providers/ClickHouse/clickhouse/latest/docs\" target=\"_blank\" rel=\"noopener noreferrer\">ClickHouse Provider</a></p>\n<p>Steps:</p>\n<p>1). Create an API Key on Cloud.\nFollow the docs here - <a href=\"https://clickhouse.com/docs/cloud/manage/openapi\" target=\"_blank\" rel=\"noopener noreferrer\">https://clickhouse.com/docs/cloud/manage/openapi</a></p>\n<p>Save the creds locally.</p>\n<p>2). Install Terraform using - <a href=\"https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli\" target=\"_blank\" rel=\"noopener noreferrer\">https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli</a></p>\n<p>You can use Homebrew package manager if you're on Mac.</p>\n<p>3). Create a directory anywhere you like:</p>\n<div class=\"wrapper_EBtA\" style=\"height:56.550000000000004px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">mkdir test\n➜  test pwd\n/Users/jaijhala/Desktop/terraform/test\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>4). Create 2 files: <code>main.tf</code> and <code>secret.tfvars</code></p>\n<p>Copy the following:</p>\n<p><code>main.tf</code> file would be:</p>\n<div class=\"wrapper_EBtA\" style=\"height:980.2px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">terraform {\n required_providers {\n   clickhouse = {\n     source = \"ClickHouse/clickhouse\"\n     version = \"0.0.2\"\n   }\n }\n}\n\nvariable \"organization_id\" {\n  type = string\n}\n\nvariable \"token_key\" {\n  type = string\n}\n\nvariable \"token_secret\" {\n  type = string\n}\n\nprovider clickhouse {\n  environment \t= \"production\"\n  organization_id = var.organization_id\n  token_key   \t= var.token_key\n  token_secret\t= var.token_secret\n}\n\n\nvariable \"service_password\" {\n  type = string\n  sensitive   = true\n}\n\nresource \"clickhouse_service\" \"service123\" {\n  name       \t= \"jai-terraform\"\n  cloud_provider = \"aws\"\n  region     \t= \"us-east-2\"\n  tier       \t= \"development\"\n  idle_scaling   = true\n  password  = var.service_password\n  ip_access = [\n\t{\n    \tsource  \t= \"0.0.0.0/0\"\n    \tdescription = \"Anywhere\"\n\t}\n  ]\n}\n\noutput \"CLICKHOUSE_HOST\" {\n  value = clickhouse_service.service123.endpoints.0.host\n}\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>You can replace your own parameters like service name, region etc.. in the resources section above.</p>\n<p><code>secret.tfvars</code> is where you'll put all the API Key related info that you downloaded earlier. The idea behind this file is that all your secret credentials will be hidden from the main config file.</p>\n<p>It would be something like (replace these parameters):</p>\n<div class=\"wrapper_EBtA\" style=\"height:75.4px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">organization_id = \"e957a5f7-4qe3-4b05-ad5a-d02b2dcd0593\"\ntoken_key = \"QWhhkMeytqQruTeKg\"\ntoken_secret = \"4b1dNmjWdLUno9lXxmKvSUcPP62jvn7irkuZPbY\"\nservice_password = \"password123!\"\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>5).  Run <code>terraform init</code> from this directory</p>\n<p>Expected output:</p>\n<div class=\"wrapper_EBtA\" style=\"height:471.25000000000006px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">Initializing the backend...\n\nInitializing provider plugins...\n- Finding clickhouse/clickhouse versions matching \"0.0.2\"...\n- Installing clickhouse/clickhouse v0.0.2...\n- Installed clickhouse/clickhouse v0.0.2 (self-signed, key ID D7089EE5C6A92ED1)\n\nPartner and community providers are signed by their developers.\nIf you'd like to know more about provider signing, you can read about it here:\nhttps://www.terraform.io/docs/cli/plugins/signing.html\n\nTerraform has created a lock file .terraform.lock.hcl to record the provider\nselections it made above. Include this file in your version control repository\nso that Terraform can guarantee to make the same selections by default when\nyou run \"terraform init\" in the future.\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>6). Run <code>terraform apply -var-file=secret.tfvars</code> command.</p>\n<p>Something like:</p>\n<div class=\"wrapper_EBtA\" style=\"height:697.45px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">➜  test terraform apply -var-file=secret.tfvars\n\nTerraform used the selected providers to generate the following execution plan. Resource actions are indicated with\nthe following symbols:\n  + create\n\nTerraform will perform the following actions:\n\n  # clickhouse_service.service123 will be created\n  + resource \"clickhouse_service\" \"service123\" {\n      + cloud_provider = \"aws\"\n      + endpoints      = (known after apply)\n      + id             = (known after apply)\n      + idle_scaling   = true\n      + ip_access      = [\n          + {\n              + description = \"Anywhere\"\n              + source      = \"0.0.0.0/0\"\n            },\n        ]\n      + last_updated   = (known after apply)\n      + name           = \"jai-terraform\"\n      + password       = (sensitive value)\n      + region         = \"us-east-2\"\n      + tier           = \"development\"\n    }\n\nPlan: 1 to add, 0 to change, 0 to destroy.\n\nChanges to Outputs:\n  + CLICKHOUSE_HOST = (known after apply)\n\nDo you want to perform these actions?\n  Terraform will perform the actions described above.\n  Only 'yes' will be accepted to approve.\n\n  Enter a value: yes\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>Type <code>yes</code> and hit enter</p>\n<p>Side note: Notice it says <code>password       = (sensitive value)</code> above.\nThis is because we set <code>sensitive   = true</code> for the password in the main.tf file.</p>\n<p>7). It will take a couple of mins to create the service but eventually it should come up like:</p>\n<div class=\"wrapper_EBtA\" style=\"height:395.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">  Enter a value: yes\n\nclickhouse_service.service123: Creating...\nclickhouse_service.service123: Still creating... [10s elapsed]\nclickhouse_service.service123: Still creating... [20s elapsed]\nclickhouse_service.service123: Still creating... [30s elapsed]\nclickhouse_service.service123: Still creating... [40s elapsed]\nclickhouse_service.service123: Still creating... [50s elapsed]\nclickhouse_service.service123: Still creating... [1m0s elapsed]\nclickhouse_service.service123: Still creating... [1m10s elapsed]\nclickhouse_service.service123: Still creating... [1m20s elapsed]\nclickhouse_service.service123: Still creating... [1m30s elapsed]\nclickhouse_service.service123: Still creating... [1m40s elapsed]\nclickhouse_service.service123: Creation complete after 1m41s [id=aa8d8d63-1878-4600-8470-630715af38ed]\n\nApply complete! Resources: 1 added, 0 changed, 0 destroyed.\n\nOutputs:\n\nCLICKHOUSE_HOST = \"h3ljlaqez6.us-east-2.aws.clickhouse.cloud\"\n➜  test\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>8). Check Cloud Console, you should be able to see the service created.</p>\n<p>9). To clean up/destroy the service again, run <code>terraform destroy -var-file=secret.tfvars</code></p>\n<p>Something like:</p>\n<div class=\"wrapper_EBtA\" style=\"height:395.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with\nthe following symbols:\n  - destroy\n\nTerraform will perform the following actions:\n\n  # clickhouse_service.service123 will be destroyed\n  - resource \"clickhouse_service\" \"service123\" {\n      - cloud_provider = \"aws\" -&gt; null\n      - ............\n\nPlan: 0 to add, 0 to change, 1 to destroy.\n\nChanges to Outputs:\n  - CLICKHOUSE_HOST = \"h3ljlaqez6.us-east-2.aws.clickhouse.cloud\" -&gt; null\n\nDo you really want to destroy all resources?\n  Terraform will destroy all your managed infrastructure, as shown above.\n  There is no undo. Only 'yes' will be accepted to confirm.\n\n  Enter a value:\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>Type yes and hit enter</p>\n<p>10).</p>\n<div class=\"wrapper_EBtA\" style=\"height:113.10000000000001px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">clickhouse_service.service123: Destroying... [id=aa8d8d63-1878-4600-8470-630715af38ed]\nclickhouse_service.service123: Still destroying... [id=aa8d8d63-1878-4600-8470-630715af38ed, 10s elapsed]\nclickhouse_service.service123: Still destroying... [id=aa8d8d63-1878-4600-8470-630715af38ed, 20s elapsed]\nclickhouse_service.service123: Destruction complete after 27s\n\nDestroy complete! Resources: 1 destroyed.\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>And it should be gone from the Cloud Console.</p>\n<p>More details about the Cloud API can be found here - <a href=\"https://clickhouse.com/docs/cloud/manage/api/api-overview\" target=\"_blank\" rel=\"noopener noreferrer\">https://clickhouse.com/docs/cloud/manage/api/api-overview</a></p><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2026-02-25T11:20:23.000Z\">Feb 25, 2026</time> · <!-- -->5 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/terraform_example",
            "title": "Terraform example on how to use Cloud API",
            "summary": "This covers an example of how you can use terraform to create/delete clusters using the API",
            "date_modified": "2026-02-25T11:20:23.000Z",
            "tags": [
                "Native Clients and Interfaces"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection",
            "content_html": "This article shows you how you can opt out of crash report collection on ClickHouse Cloud<!-- -->\n<!-- -->\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"overview\">Overview<a href=\"https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection#overview\" class=\"hash-link\" aria-label=\"Direct link to Overview\" title=\"Direct link to Overview\">​</a></h2>\n<p>Starting <strong>February 27, 2026</strong>, ClickHouse Cloud will begin collecting crash reports when server crashes occur. This is part of our commitment to improving service reliability for all our users.</p>\n<p>Crash report collection helps us:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Identify and understand what caused a crash</li>\n<li class=\"custom-li\">Fix issues more quickly</li>\n<li class=\"custom-li\">Continuously improve your service experience</li>\n</ul>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"whats-collected\">What's collected<a href=\"https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection#whats-collected\" class=\"hash-link\" aria-label=\"Direct link to What's collected\" title=\"Direct link to What's collected\">​</a></h2>\n<p>When a crash occurs, crash reports capture a snapshot of the server's state at that moment. We want to be transparent that this may include sensitive information that was in memory, such as:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Connection credentials</li>\n<li class=\"custom-li\">Encryption keys</li>\n<li class=\"custom-li\">Query strings</li>\n<li class=\"custom-li\">Other data in memory at the time of the crash</li>\n</ul>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"how-we-protect-your-data\">How we protect your data<a href=\"https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection#how-we-protect-your-data\" class=\"hash-link\" aria-label=\"Direct link to How we protect your data\" title=\"Direct link to How we protect your data\">​</a></h3>\n<p>We take the security of this data seriously:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\"><strong>Regional Storage</strong>: All data stays in the same region as your service</li>\n<li class=\"custom-li\"><strong>Enhanced Security</strong>: We apply additional protections to all collected data</li>\n<li class=\"custom-li\"><strong>Limited Retention</strong>: Data is kept only as long as needed for debugging, then securely deleted</li>\n</ul>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"services-automatically-excluded\">Services automatically excluded<a href=\"https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection#services-automatically-excluded\" class=\"hash-link\" aria-label=\"Direct link to Services automatically excluded\" title=\"Direct link to Services automatically excluded\">​</a></h2>\n<p>Some services are automatically excluded from crash report collection:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Services with <strong>HIPAA</strong> compliance requirements</li>\n<li class=\"custom-li\">Services with <strong>PCI</strong> compliance requirements</li>\n<li class=\"custom-li\"><strong>BYOC</strong> (Bring Your Own Cloud) services</li>\n</ul>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"how-to-opt-out\">How to opt out<a href=\"https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection#how-to-opt-out\" class=\"hash-link\" aria-label=\"Direct link to How to opt out\" title=\"Direct link to How to opt out\">​</a></h2>\n<p>If you'd prefer not to participate in crash report collection, you can easily opt out:</p>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">Go to the <a href=\"https://clickhouse.cloud/\" target=\"_blank\" rel=\"noopener noreferrer\">ClickHouse Cloud Console</a></li>\n<li class=\"custom-li\">Select your service</li>\n<li class=\"custom-li\">Click on the <strong>Settings</strong> tab</li>\n<li class=\"custom-li\">Scroll to find \"Share crash reports with ClickHouse\"</li>\n<li class=\"custom-li\">Toggle the option off to opt out</li>\n</ol>\n<div style=\"position:relative;margin-bottom:16px;margin-top:16px\"><div style=\"cursor:default\"><div style=\"background-size:cover;background-repeat:no-repeat;position:relative;background-image:url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAJCAYAAAALpr0TAAAACXBIWXMAABYlAAAWJQFJUiTwAAAA50lEQVR4nEWO227EMAhE8///2NsmrTZrsomFL9hApnLaqg9ISBxmzsSccq3ixxFtP6JJa5ZysVrFzKwDwHme79NGpC1lqBl6V5idYM5oY3f4AN2xTBSCxnlGYgYzo7WGUso17n6BAJYp56xVBLUU5FLRewcRgWjDfux+/oHMSVu338fhA4RnwOd6w7qtPm6qtkwAdAC1CmIc1f3yy9KG94/jSLxAdxyvb9iXLzQi5PsKCQTddwcz/Ij/YP24Ic0L+vpAu9+hjwc0kIM2+PO5TKUUVtVWcxVag6TI0oqI5CpSapEscPOXbznhW7LoAUHbAAAAAElFTkSuQmCC&quot;);width:600px;margin:0 auto;display:block;box-shadow:none\"><svg style=\"width:100%;height:auto;max-width:100%;margin-bottom:-4px\" width=\"1024\" height=\"945\"></svg><noscript><img style=width:100%;height:auto;max-width:100%;margin-bottom:-4px;position:absolute;top:0;left:0 src=/docs/assets/ideal-img/crash-reports.a047ec5.48.png srcset=\"/docs/assets/ideal-img/crash-reports.a047ec5.48.png 48w,/docs/assets/ideal-img/crash-reports.90138d6.300.png 300w,/docs/assets/ideal-img/crash-reports.d3e93cb.600.png 600w,/docs/assets/ideal-img/crash-reports.6fb73cc.1024.png 1024w\" alt=\"Where to find the opt out option in Cloud UI\" width=1024 height=945></noscript></div></div></div>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Note</div><p>In addition to the service setting, we also support configuring preferences for the organization. If the setting is disabled, i.e., opt out of the crash report collection, all existing and new services will be opted out automatically. If you set the preference to enabled i.e. opt in, you can selectively disable at the service level to override and opt out.</p></div></div>\n<div style=\"position:relative;margin-bottom:16px;margin-top:16px\"><div style=\"cursor:default\"><div style=\"background-size:cover;background-repeat:no-repeat;position:relative;background-image:url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAADCAYAAACqPZ51AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAZUlEQVR4nB2N2wqDMBAF8x1V4yYrqYZcSrv1qeD/f9UU83BgYGCOy/lJ7wXvJ1SF87Sx40gEWVD1iCy4WjPX9cPsTUqKfT+DzYx9V2rVEXAxCqqBGFe2LdBfjdYKpWRuN8+P8fYHkIwsJmMGPUwAAAAASUVORK5CYII=&quot;);width:600px;margin:0 auto;display:block;box-shadow:none\"><svg style=\"width:100%;height:auto;max-width:100%;margin-bottom:-4px\" width=\"1024\" height=\"276\"></svg><noscript><img style=width:100%;height:auto;max-width:100%;margin-bottom:-4px;position:absolute;top:0;left:0 src=/docs/assets/ideal-img/crash-reports-collection.f7f3155.48.png srcset=\"/docs/assets/ideal-img/crash-reports-collection.f7f3155.48.png 48w,/docs/assets/ideal-img/crash-reports-collection.40796fa.300.png 300w,/docs/assets/ideal-img/crash-reports-collection.519722e.600.png 600w,/docs/assets/ideal-img/crash-reports-collection.d1cd23f.1024.png 1024w\" alt=\"Crash reports collection\" width=1024 height=276></noscript></div></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2026-02-04T00:00:00.000Z\">Feb 4, 2026</time> · <!-- -->2 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection",
            "title": "How to opt out of crash report collection",
            "summary": "This article shows you how you can opt out of crash report collection on ClickHouse Cloud",
            "date_modified": "2026-02-04T00:00:00.000Z",
            "tags": [
                "Managing Cloud"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats",
            "content_html": "Learn about the different part types (Wide vs Compact) and storage formats (Full vs Packed) in ClickHouse, and how they affect performance.<!-- -->\n<!-- -->\n<br>\n<br>\n<p>ClickHouse uses two independent concepts for organizing data within parts:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\"><strong>Part types</strong> (Wide vs Compact): How column data is stored within a part</li>\n<li class=\"custom-li\"><strong>Storage formats</strong> (Full vs Packed): How the part's files are stored on disk</li>\n</ul>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"part-types-wide-vs-compact\">Part types: Wide vs Compact<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#part-types-wide-vs-compact\" class=\"hash-link\" aria-label=\"Direct link to Part types: Wide vs Compact\" title=\"Direct link to Part types: Wide vs Compact\">​</a></h2>\n<p>Part types determine how column data is organized within a data part.</p>\n<table><thead><tr><th>Type</th><th>Description</th><th>Best for</th></tr></thead><tbody><tr><td><strong>Wide</strong></td><td>Each column is stored in separate file(s), each with its own <a href=\"https://clickhouse.com/docs/concepts/glossary#mark-file\">marks file</a></td><td>Queries selecting a subset of columns</td></tr><tr><td><strong>Compact</strong></td><td>All columns are stored in a single file with a single <a href=\"https://clickhouse.com/docs/concepts/glossary#mark-file\">marks file</a></td><td>Ingestion performance and queries needing all columns</td></tr></tbody></table>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"when-each-type-is-used\">When each type is used<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#when-each-type-is-used\" class=\"hash-link\" aria-label=\"Direct link to When each type is used\" title=\"Direct link to When each type is used\">​</a></h3>\n<p>The part type is controlled by the following table settings:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\"><a href=\"https://clickhouse.com/docs/operations/settings/merge-tree-settings#min_bytes_for_wide_part\"><code>min_bytes_for_wide_part</code></a>: Minimum bytes for a part to use Wide format</li>\n<li class=\"custom-li\"><a href=\"https://clickhouse.com/docs/operations/settings/merge-tree-settings#min_rows_for_wide_part\"><code>min_rows_for_wide_part</code></a>: Minimum rows for a part to use Wide format</li>\n</ul>\n<p>If either the number of bytes or rows in a data part is less than the corresponding setting value, the part is stored in <code>Compact</code> format; otherwise, it uses <code>Wide</code> format.</p>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"performance-considerations\">Performance considerations<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#performance-considerations\" class=\"hash-link\" aria-label=\"Direct link to Performance considerations\" title=\"Direct link to Performance considerations\">​</a></h3>\n<p><strong>Compact parts:</strong></p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Better ingestion performance</li>\n<li class=\"custom-li\">Optimal when queries need all columns</li>\n<li class=\"custom-li\">More efficient for small parts</li>\n</ul>\n<p><strong>Wide parts:</strong></p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">More efficient for queries selecting only a subset of columns</li>\n<li class=\"custom-li\">Better for large datasets with selective column access</li>\n</ul>\n<p>Compact-to-wide merges are slower than wide-to-wide merges because ClickHouse uses <a href=\"https://clickhouse.com/docs/merges#memory-optimized-merges\">vertical merge</a> algorithms for compact-to-wide conversions, while using horizontal algorithms for compact-to-compact merges. If you want to force the use of wide parts regardless of size, you can set <code>min_bytes_for_wide_part=0</code>.</p>\n<p>This can be useful in the following scenarios:</p>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">When you have tables with many columns (e.g. over 600 columns) and are making large inserts, setting this to 0 can help with performance</li>\n<li class=\"custom-li\">For optimizing memory usage of system tables like <code>system.metric_log</code> and <code>system.text_log</code> that are consuming excessive memory during merges</li>\n<li class=\"custom-li\">When dealing with tables that have high insert volumes and you want to optimize storage and merge behavior</li>\n<li class=\"custom-li\">When you want consistent part format behavior and don't want the overhead of format transitions based on size thresholds</li>\n</ol>\n<p>It's worth noting that while setting this to 0 can improve certain performance characteristics, it may generate more GET requests to S3 storage due to the wide parts format.</p>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"limitations\">Limitations<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#limitations\" class=\"hash-link\" aria-label=\"Direct link to Limitations\" title=\"Direct link to Limitations\">​</a></h3>\n<p>Column size statistics are not calculated for compact parts, which can affect monitoring and optimization efforts. When querying <code>system.parts_columns</code>, compact parts show <code>0</code> for <code>column_data_compressed_bytes</code> and <code>column_data_uncompressed_bytes</code>. For more information see <a href=\"https://clickhouse.com/docs/knowledgebase/count-parts-by-type\">\"Find counts and sizes of wide or compact parts\"</a>.</p>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"storage-formats-full-vs-packed-clickhouse-cloud\">Storage formats: Full vs Packed (ClickHouse Cloud)<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#storage-formats-full-vs-packed-clickhouse-cloud\" class=\"hash-link\" aria-label=\"Direct link to Storage formats: Full vs Packed (ClickHouse Cloud)\" title=\"Direct link to Storage formats: Full vs Packed (ClickHouse Cloud)\">​</a></h2>\n<p>Storage formats determine how a part's files are physically stored on disk.</p>\n<table><thead><tr><th>Format</th><th>Description</th><th>Availability</th></tr></thead><tbody><tr><td><strong>Full</strong></td><td>Each file is stored individually in the part directory</td><td>Open source and Cloud</td></tr><tr><td><strong>Packed</strong></td><td>All files are bundled into a single archive file</td><td>ClickHouse Cloud only</td></tr></tbody></table>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"full-storage\">Full storage<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#full-storage\" class=\"hash-link\" aria-label=\"Direct link to Full storage\" title=\"Direct link to Full storage\">​</a></h3>\n<p>In Full storage, each part consists of multiple separate files stored individually on disk. This is the default and only option in open source ClickHouse.</p>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"packed-storage-clickhouse-cloud-only\">Packed storage (ClickHouse Cloud only)<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#packed-storage-clickhouse-cloud-only\" class=\"hash-link\" aria-label=\"Direct link to Packed storage (ClickHouse Cloud only)\" title=\"Direct link to Packed storage (ClickHouse Cloud only)\">​</a></h3>\n<p>In Packed storage, all part files are bundled into a single archive. This significantly reduces the number of file operations, which is critical for remote storage like S3 where each request has associated latency and cost.</p>\n<p><strong>Benefits of Packed storage:</strong></p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Fewer S3/object storage API calls</li>\n<li class=\"custom-li\">Reduced metadata pressure on the coordination service</li>\n<li class=\"custom-li\">Lower storage costs (full storage can be significantly more expensive)</li>\n<li class=\"custom-li\">Better performance for small parts on remote storage</li>\n</ul>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"when-packed-storage-is-used\">When Packed storage is used<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#when-packed-storage-is-used\" class=\"hash-link\" aria-label=\"Direct link to When Packed storage is used\" title=\"Direct link to When Packed storage is used\">​</a></h3>\n<p>In ClickHouse Cloud, a part uses Packed storage if <strong>any</strong> of these conditions are true:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Uncompressed bytes &lt; <a href=\"https://clickhouse.com/docs/operations/settings/merge-tree-settings#min_bytes_for_full_part_storage\"><code>min_bytes_for_full_part_storage</code></a></li>\n<li class=\"custom-li\">Row count &lt; <a href=\"https://clickhouse.com/docs/operations/settings/merge-tree-settings#min_rows_for_full_part_storage\"><code>min_rows_for_full_part_storage</code></a></li>\n<li class=\"custom-li\">Merge level &lt; <a href=\"https://clickhouse.com/docs/operations/settings/merge-tree-settings#min_level_for_full_part_storage\"><code>min_level_for_full_part_storage</code></a></li>\n</ul>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Open source</div><p>While the settings <code>min_bytes_for_full_part_storage</code>, <code>min_rows_for_full_part_storage</code>, and <code>min_level_for_full_part_storage</code> are defined in open source ClickHouse, they have no effect because the Packed storage implementation is only available in ClickHouse Cloud.</p></div></div>\n<p>The <code>min_level_for_full_part_storage</code> setting can be used to optimize both performance and costs in ClickHouse Cloud environments, particularly for tables that receive continuous inserts.\nThe setting is available starting in ClickHouse version 25.10 and works in conjunction with <code>min_level_for_wide_part</code> to provide comprehensive control over part storage strategies.</p>\n<p>Changing it from the default value (0) could be considered in the following use cases:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">When tables receive regular data ingestion, initial parts will be merged away quickly, making it wasteful to store them in full part format initially</li>\n<li class=\"custom-li\">Setting this parameter prevents expensive S3 PUT requests during inserts. For example, one analysis showed that inserts creating full parts averaged 31.3 PUT requests per insert, while those creating only packed parts averaged just 2.22 PUT requests per insert</li>\n<li class=\"custom-li\">Insert operations become faster, especially for tables with many columns, since packed storage writes all data into one file rather than creating separate files for each column.</li>\n</ul>\n<p>Recommended configuration:</p>\n<p>Set <code>min_level_for_full_part_storage = 2</code> for cloud deployments.\nThis ensures that:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Level 0 parts (initial inserts) use packed storage</li>\n<li class=\"custom-li\">Level 1 parts continue using packed storage</li>\n<li class=\"custom-li\">Only parts at level 2 and above use full storage format</li>\n</ul>\n<div class=\"theme-admonition theme-admonition-tip alert alert--success admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 12 16\"><path fill-rule=\"evenodd\" d=\"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Tip</div><p>Avoid this setting for tables that receive very large but infrequent writes where insufficient merges occur, as large initial writes may benefit from full part storage immediately.</p></div></div>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"combining-part-types-and-storage-formats\">Combining part types and storage formats<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#combining-part-types-and-storage-formats\" class=\"hash-link\" aria-label=\"Direct link to Combining part types and storage formats\" title=\"Direct link to Combining part types and storage formats\">​</a></h2>\n<p>These two concepts are orthogonal and you can have any combination, depending on if you are using ClickHouse Cloud or Open Source ClickHouse:</p>\n<table><thead><tr><th>Combination</th><th>Use case</th></tr></thead><tbody><tr><td>Wide + Full</td><td>Large parts on local storage (default in open source)</td></tr><tr><td>Wide + Packed</td><td>Large parts on cloud storage</td></tr><tr><td>Compact + Full</td><td>Small parts on local storage</td></tr><tr><td>Compact + Packed</td><td>Small parts on cloud storage</td></tr></tbody></table>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"querying-part-information\">Querying part information<a href=\"https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats#querying-part-information\" class=\"hash-link\" aria-label=\"Direct link to Querying part information\" title=\"Direct link to Querying part information\">​</a></h2>\n<p>You can inspect the part type and part storage type of existing parts using the <a href=\"https://clickhouse.com/docs/operations/system-tables/parts\"><code>system.parts</code></a> table:</p>\n<div class=\"wrapper_EBtA\" style=\"height:282.75px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">SELECT\n    part_type,\n    part_storage_type,\n    max(level),\n    count(),\n    formatReadableSize(max(data_uncompressed_bytes)),\n    formatReadableSize(min(data_uncompressed_bytes))\nFROM system.parts\nWHERE (database != 'system') AND active\nGROUP BY\n    1,\n    2\nORDER BY\n    1 ASC,\n    2 ASC\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>You will see something like this:</p>\n<div class=\"wrapper_EBtA\" style=\"height:113.10000000000001px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-response\"><code class=\"language-response\">   ┌─part_type─┬─part_storage_type─┬─max(level)─┬─count()─┬─formatReadab⋯sed_bytes))─┬─formatReadab⋯sed_bytes))─┐\n1. │ Compact   │ Full              │      12688 │    2456 │ 1023.87 MiB              │ 23.78 MiB                │\n2. │ Compact   │ Packed            │      97383 │   13748 │ 127.77 MiB               │ 1.00 B                   │\n3. │ Wide      │ Full              │       7642 │    2000 │ 1.38 TiB                 │ 30.18 MiB                │\n4. │ Wide      │ Packed            │         10 │     187 │ 110.01 MiB               │ 1.30 KiB                 │\n   └───────────┴───────────────────┴────────────┴─────────┴──────────────────────────┴──────────────────────────┘\n</code></pre></div><div class=\"activity_PoTP\"></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2026-02-03T00:00:00.000Z\">Feb 3, 2026</time> · <!-- -->6 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats",
            "title": "Understanding part types and storage formats",
            "summary": "Learn about the different part types (Wide vs Compact) and storage formats (Full vs Packed) in ClickHouse, and how they affect performance.",
            "date_modified": "2026-02-03T00:00:00.000Z",
            "tags": [
                "Core Data Concepts"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/count-parts-by-type",
            "content_html": "This knowledgebase article shows you how to find part counts by the type of part - wide or compact.<!-- -->\n<!-- -->\n<br>\n<p>The following query can be used to count the number of parts by type:</p>\n<div class=\"wrapper_EBtA\" style=\"height:226.20000000000002px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">SELECT\n    table,\n    part_type,\n    count(*)\nFROM system.parts\nWHERE active\nGROUP BY\n    table,\n    part_type\nORDER BY\n    table ASC,\n    part_type ASC\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>An example response is shown below:</p>\n<div class=\"wrapper_EBtA\" style=\"height:207.35000000000002px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-response\"><code class=\"language-response\">┌─table───────────────────┬─part_type─┬─count()─┐\n│ asynchronous_metric_log │ Compact   │       6 │\n│ metric_log              │ Compact   │       1 │\n│ otel_logs               │ Compact   │       5 │\n│ otel_logs               │ Wide      │       2 │\n│ part_log                │ Compact   │       2 │\n│ query_log               │ Compact   │       5 │\n│ session_log             │ Compact   │       2 │\n│ text_log                │ Compact   │       7 │\n│ trace_log               │ Compact   │       6 │\n└─────────────────────────┴───────────┴─────────┘\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>Run the query below to query part size for wide and compact parts:</p>\n<div class=\"wrapper_EBtA\" style=\"height:320.45000000000005px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">SELECT\n    table,\n    column,\n    part_type,\n    sum(rows),\n    sum(column_data_compressed_bytes),\n    sum(column_data_uncompressed_bytes)\nFROM system.parts_columns\nWHERE active\nGROUP BY\n    table,\n    column,\n    part_type\nORDER BY\n    table ASC,\n    column ASC,\n    part_type ASC\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>An example response is shown below:</p>\n<div class=\"wrapper_EBtA\" style=\"height:414.70000000000005px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-response\"><code class=\"language-response\">┌─table─────┬─column─────────────┬─part_type─┬─sum(rows)─┬─sum(column_data_compressed_bytes)─┬─sum(column_data_uncompressed_bytes)─┐\n│ otel_logs │ Body               │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ Body               │ Wide      │  18900157 │                         316784170 │                          2807508947 │\n│ otel_logs │ LogAttributes      │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ LogAttributes      │ Wide      │  18900157 │                         215812392 │                          3173566494 │\n│ otel_logs │ ResourceAttributes │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ ResourceAttributes │ Wide      │  18900157 │                          94428129 │                          2258154988 │\n│ otel_logs │ ServiceName        │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ ServiceName        │ Wide      │  18900157 │                             24726 │                            18973727 │\n│ otel_logs │ SeverityNumber     │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ SeverityNumber     │ Wide      │  18900157 │                             51973 │                            75600628 │\n│ otel_logs │ SeverityText       │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ SeverityText       │ Wide      │  18900157 │                             24726 │                            18973727 │\n│ otel_logs │ SpanId             │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ SpanId             │ Wide      │  18900157 │                             13048 │                            18900157 │\n│ otel_logs │ Timestamp          │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ Timestamp          │ Wide      │  18900157 │                          61225801 │                           151201256 │\n│ otel_logs │ TraceFlags         │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ TraceFlags         │ Wide      │  18900157 │                             51973 │                            75600628 │\n│ otel_logs │ TraceId            │ Compact   │   1564357 │                                 0 │                                   0 │\n│ otel_logs │ TraceId            │ Wide      │  18900157 │                             13048 │                            18900157 │\n└───────────┴────────────────────┴───────────┴───────────┴───────────────────────────────────┴─────────────────────────────────────┘\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Compact part size shows as zero</div><p>Note that columns sizes are not calculated in compact parts and they therefore show as <code>0</code> above.</p></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2026-01-12T00:00:00.000Z\">Jan 12, 2026</time> · <!-- -->3 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/count-parts-by-type",
            "title": "Find counts and sizes of wide or compact parts",
            "summary": "This knowledgebase article shows you how to find part counts by the type of part - wide or compact.",
            "date_modified": "2026-01-12T00:00:00.000Z",
            "tags": [
                "Troubleshooting"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces",
            "content_html": "This guide shows you how to collect and draw query traces with self-managed ClickHouse using either built-in methods or using Grafana. This is particularly useful when you're working with complex queries and need to understand the internal execution mechanics beyond what EXPLAIN provides.<!-- -->\n<!-- -->\n<br>\n<br>\n<p><strong>Prerequisites</strong>:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Familiarity with ClickHouse <a href=\"https://clickhouse.com/docs/operations/configuration-files\">config files</a></li>\n<li class=\"custom-li\">A running instance of <a href=\"https://clickhouse.com/docs/install\">ClickHouse server</a></li>\n<li class=\"custom-li\">(Optional) A running local <a href=\"https://grafana.com/docs/grafana/latest/fundamentals/getting-started/\" target=\"_blank\" rel=\"noopener noreferrer\">Grafana instance</a></li>\n</ul>\n<div class=\"sc-xro1ly-0 QlHdI vertical-stepper \"><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-0\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Check that  system table is enabled</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"enable-system-table\">Check that <code>opentelemetry_span_log</code> system table is enabled<a href=\"https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces#enable-system-table\" class=\"hash-link\" aria-label=\"Direct link to enable-system-table\" title=\"Direct link to enable-system-table\">​</a></h2><p>If you have not made any modifications to the <code>opentelemetry_span_log</code> section of <code>config.xml</code> you can skip this step.</p><p>Open your default ClickHouse <code>config.xml</code> file and find the following section:</p><div class=\"wrapper_EBtA\" style=\"height:546.6500000000001px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-yaml\"><code class=\"language-yaml\">&lt;!--\n    OpenTelemetry log contains OpenTelemetry trace spans.\n\n    NOTE: this table does not use standard schema with event_date and event_time!\n--&gt;\n&lt;opentelemetry_span_log&gt;\n    &lt;!--\n        The default table creation code is insufficient, this &lt;engine&gt; spec\n        is a workaround. There is no 'event_time' for this log, but two times,\n        start and finish. It is sorted by finish time, to avoid inserting\n        data too far away in the past (probably we can sometimes insert a span\n        that is seconds earlier than the last span in the table, due to a race\n        between several spans inserted in parallel). This gives the spans a\n        global order that we can use to e.g. retry insertion into some external\n        system.\n    --&gt;\n    &lt;engine&gt;\n        engine MergeTree\n        partition by toYYYYMM(finish_date)\n        order by (finish_date, finish_time_us, trace_id)\n    &lt;/engine&gt;\n    &lt;database&gt;system&lt;/database&gt;\n    &lt;table&gt;opentelemetry_span_log&lt;/table&gt;\n    &lt;flush_interval_milliseconds&gt;7500&lt;/flush_interval_milliseconds&gt;\n    &lt;max_size_rows&gt;1048576&lt;/max_size_rows&gt;\n    &lt;reserved_size_rows&gt;8192&lt;/reserved_size_rows&gt;\n    &lt;buffer_size_rows_flush_threshold&gt;524288&lt;/buffer_size_rows_flush_threshold&gt;\n    &lt;flush_on_crash&gt;false&lt;/flush_on_crash&gt;\n&lt;/opentelemetry_span_log&gt;\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>Make sure that it is not commented out, or else you won't be able to see <code>system.opentelemetry_span_log</code> in the following steps.\nThis can also be the case if your ClickHouse server is not using the default configuration file.</p><p>Check your server logs for something like:</p><div class=\"wrapper_EBtA\" style=\"height:37.7px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">Processing configuration file 'config.xml'.\nThere is no file 'config.xml', will use embedded config.\n</code></pre></div><div class=\"activity_PoTP\"></div></div><div class=\"theme-admonition theme-admonition-tip alert alert--success admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 12 16\"><path fill-rule=\"evenodd\" d=\"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Tip</div><p>In standard installations this file is located at <code>/etc/clickhouse-server/config.xml</code></p></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-1\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Enable OpenTelemetry tracing</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"enable-otel-tracing\">Enable OpenTelemetry tracing<a href=\"https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces#enable-otel-tracing\" class=\"hash-link\" aria-label=\"Direct link to Enable OpenTelemetry tracing\" title=\"Direct link to Enable OpenTelemetry tracing\">​</a></h2><p>With your ClickHouse server running, open ClickHouse client and enable trace collection using the following query:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-bash\"><code class=\"language-bash\">SET opentelemetry_trace_processors=1;\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>You should now see the <code>opentelemetry_span_log</code> system table if you run:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">SHOW TABLES IN system\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>Next run:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-txt\"><code class=\"language-txt\">SET opentelemetry_start_trace_probability=1;\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>This sets the probability that the ClickHouse can start a trace for executed queries, where\n<code>1</code> means that the trace is enabled for all executed queries.</p></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-2\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Obtain a query ID</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"obtain-query-id\">Obtain a query ID<a href=\"https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces#obtain-query-id\" class=\"hash-link\" aria-label=\"Direct link to Obtain a query ID\" title=\"Direct link to Obtain a query ID\">​</a></h2><p>Run the following dummy query, or the query you are interested in tracing:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">SELECT pow(number, 2) FROM numbers(10E4);\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>Copy the query id:</p><div class=\"wrapper_EBtA\" style=\"height:131.95000000000002px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">:) SELECT pow(number, 2) FROM numbers(10E4);\n\nSELECT pow(number, 2)\nFROM numbers(100000.)\n\n--highlight-next-line\nQuery id: a9241258-a0c4-4776-a00b-e6a1d9bec4a1\n</code></pre></div><div class=\"activity_PoTP\"></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-3\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Generate a trace file</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"generate-trace-file\">Generate a trace file<a href=\"https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces#generate-trace-file\" class=\"hash-link\" aria-label=\"Direct link to Generate a trace file\" title=\"Direct link to Generate a trace file\">​</a></h2><p>Run the following query, substituting in the query ID you obtained in the previous step:</p><div class=\"wrapper_EBtA\" style=\"height:414.70000000000005px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">WITH 'a9241258-a0c4-4776-a00b-e6a1d9bec4a1' AS my_query_id\nSELECT\n    concat(substring(hostName(), length(hostName()), 1), leftPad(greatest(attribute['clickhouse.thread_id'], attribute['thread_number']), 5, '0')) AS group,\n    operation_name,\n    start_time_us,\n    finish_time_us,\n    sipHash64(operation_name) AS color,\n    attribute\nFROM system.opentelemetry_span_log\nWHERE (trace_id IN (\n    SELECT trace_id\n    FROM system.opentelemetry_span_log\n    WHERE (attribute['clickhouse.query_id']) = my_query_id\n)) AND (operation_name != 'query') AND (operation_name NOT LIKE 'Query%')\nORDER BY\n    hostName() ASC,\n    group ASC,\n    parent_span_id ASC,\n    start_time_us ASC\nINTO OUTFILE 'trace.json'\nFORMAT JSON\nSETTINGS output_format_json_named_tuples_as_objects = 1\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>This will write the trace to a file named <code>trace.json</code>.\nBy default, this file is created in the current working directory from which you are running the clickhouse-client or clickhouse-local tool.</p></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-4\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Visualize trace using built-in tooling</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"visualize-trace-using-built-in-tooling\">Visualize trace using built-in tooling<a href=\"https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces#visualize-trace-using-built-in-tooling\" class=\"hash-link\" aria-label=\"Direct link to Visualize trace using built-in tooling\" title=\"Direct link to Visualize trace using built-in tooling\">​</a></h2><p>Use the hosted trace visualizer at <a href=\"https://trace-visualizer.clickhouse.com/\" target=\"_blank\" rel=\"noopener noreferrer\">https://trace-visualizer.clickhouse.com/</a>.\nLoad the <code>trace.json</code> file from the previous step to visualize the trace.</p><div style=\"position:relative;margin-bottom:16px;margin-top:16px\"><div style=\"cursor:default\"><div style=\"background-size:cover;background-repeat:no-repeat;position:relative;background-image:url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAFCAYAAAB8ZH1oAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAtUlEQVR4nFXKLQvCUBjF8X0mg0UxGPwKBqugQS2C3SR+AIvNoggTfAsaDFo0rWxl4FAMvm1gcGG793nukV0tlgN/zs8giqXnBWppOuqwdtV+dVTW9qyiKFZCCAYAIcTDAMD27opaeoJGZopyaoh6bow4osSoZIjI19CxPBTzTZQKLXQqM2xGLhRr8w+DIMBibaLb7qGaHeB5CZMfTF+tITNHzCwByPsplPO+LV/+WzcRiR+8fQDi3q+f0MmYHQAAAABJRU5ErkJggg==&quot;);width:600px;margin:0 auto;display:block;box-shadow:none\"><svg style=\"width:100%;height:auto;max-width:100%;margin-bottom:-4px\" width=\"1024\" height=\"521\"></svg><noscript><img style=width:100%;height:auto;max-width:100%;margin-bottom:-4px;position:absolute;top:0;left:0 src=/docs/assets/ideal-img/trace-visualizer-example.5222c80.48.png srcset=\"/docs/assets/ideal-img/trace-visualizer-example.5222c80.48.png 48w,/docs/assets/ideal-img/trace-visualizer-example.17abc41.300.png 300w,/docs/assets/ideal-img/trace-visualizer-example.1891476.600.png 600w,/docs/assets/ideal-img/trace-visualizer-example.ca4448d.1024.png 1024w\" alt=\"ClickHouse trace visualizer example\" width=1024 height=521></noscript></div></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-5\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Using Grafana to visualize traces</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"using-grafana\">Using Grafana to visualize traces<a href=\"https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces#using-grafana\" class=\"hash-link\" aria-label=\"Direct link to Using Grafana to visualize traces\" title=\"Direct link to Using Grafana to visualize traces\">​</a></h2><p>We recommend Grafana for visualizing and exploring trace data using the official ClickHouse plugin.\nThe plugin has been enhanced to allow visualization of traces using the Trace Panel.\nThis is supported as both a visualization and as a component in Explore.</p><p>Follow the steps described in <a href=\"https://clickhouse.com/docs/observability/grafana\" target=\"_blank\" rel=\"noopener noreferrer\">\"Using Grafana and ClickHouse for Observability\"</a>\nto set up Grafana with the ClickHouse plugin.</p><p>From the Explore tab you can then run the following query, replacing the <code>trace_id</code> with your own:</p><div class=\"wrapper_EBtA\" style=\"height:207.35000000000002px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-sql\"><code class=\"language-sql\">SELECT\n    toString(trace_id) AS traceID,\n    toString(span_id) AS spanID,\n    if(toString(parent_span_id)='0', '', toString(parent_span_id)) AS parentSpanID,\n    'ClickHouse' AS serviceName,\n    operation_name AS operationName,\n    start_time_us/1000000 AS startTime,\n    (finish_time_us - start_time_us)/1000 AS duration,\n    arrayMap(key -&gt; map('key', key, 'value', attribute[key]), mapKeys(attribute)) AS serviceTags\nFROM system.opentelemetry_span_log\nWHERE trace_id = '68a14b27-a61f-596d-3746-2b03d2530e42' ORDER BY startTime ASC\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>Make sure to set <code>Query type</code> to <code>Traces</code>:</p><div style=\"position:relative;margin-bottom:16px;margin-top:16px\"><div style=\"cursor:default\"><div style=\"background-size:cover;background-repeat:no-repeat;position:relative;background-image:url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAADCAYAAACqPZ51AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAb0lEQVR4nAXBixHCIBAFQGpIFMPxPSAhqKMd2H8rSQsZ3rmrat0v5xlcGmLeQY5BLsFQhPV5MG/Sv79D9fYeMWQxjoVLl3V7SXAsloLMmkCLl5A+pyKXroUCHsaj1I62PmEpwNiEu7ZjuhmZZn38Abk9KHzHr6BqAAAAAElFTkSuQmCC&quot;);width:600px;margin:0 auto;display:block;box-shadow:none\"><svg style=\"width:100%;height:auto;max-width:100%;margin-bottom:-4px\" width=\"1024\" height=\"338\"></svg><noscript><img style=width:100%;height:auto;max-width:100%;margin-bottom:-4px;position:absolute;top:0;left:0 src=/docs/assets/ideal-img/trace-visualization-grafana.0d1a8a4.48.png srcset=\"/docs/assets/ideal-img/trace-visualization-grafana.0d1a8a4.48.png 48w,/docs/assets/ideal-img/trace-visualization-grafana.1b6033f.300.png 300w,/docs/assets/ideal-img/trace-visualization-grafana.bbe5fed.600.png 600w,/docs/assets/ideal-img/trace-visualization-grafana.aaa2656.1024.png 1024w\" alt=\"ClickHouse trace visualization in Grafana\" width=1024 height=338></noscript></div></div></div><p>Click \"Run Query\" and inspect the trace diagram:</p><div style=\"position:relative;margin-bottom:16px;margin-top:16px\"><div style=\"cursor:default\"><div style=\"background-size:cover;background-repeat:no-repeat;position:relative;background-image:url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAECAYAAAC3OK7NAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAm0lEQVR4nBXFSQ6CMBQA0F5CGSwt/R0IkwwKGgkuSNSYeP8TGMMVtNJvfJtHBGibpKXLisbFYFzEwG2ocCEVjjK5MK5QmOZF/JAtWVFiUW1RSIkxSAQpUWqNoJRTxiCP+UzWPn0naW53fW//t4fOXh43O0yjrbv9p9q1mGT5k/hB9AWd4nE8Y1G32A0nnO5X5KBx5VHnBQy9IJp/Jsw6B8W2CtoAAAAASUVORK5CYII=&quot;);width:600px;margin:0 auto;display:block;box-shadow:none\"><svg style=\"width:100%;height:auto;max-width:100%;margin-bottom:-4px\" width=\"1024\" height=\"448\"></svg><noscript><img style=width:100%;height:auto;max-width:100%;margin-bottom:-4px;position:absolute;top:0;left:0 src=/docs/assets/ideal-img/trace-visualization-diagram.438f522.48.png srcset=\"/docs/assets/ideal-img/trace-visualization-diagram.438f522.48.png 48w,/docs/assets/ideal-img/trace-visualization-diagram.ad2c1a3.300.png 300w,/docs/assets/ideal-img/trace-visualization-diagram.bf5c347.600.png 600w,/docs/assets/ideal-img/trace-visualization-diagram.5818ac5.1024.png 1024w\" alt=\"ClickHouse trace visualization in Grafana\" width=1024 height=448></noscript></div></div></div></div></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2025-12-30T00:00:00.000Z\">Dec 30, 2025</time> · <!-- -->4 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces",
            "title": "How to collect and draw a query trace",
            "summary": "This guide shows you how to collect and draw query traces with self-managed ClickHouse using either built-in methods or using Grafana. This is particularly useful when you're working with complex queries and need to understand the internal execution mechanics beyond what EXPLAIN provides.",
            "date_modified": "2025-12-30T00:00:00.000Z",
            "tags": [
                "Tools and Utilities"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure",
            "content_html": "This article explains how to recover data when using replicated tables in atomic databases in ClickHouse and disks/storage on one of the replica is lost/currupted.<!-- -->\n<!-- -->\n<br>\n<br>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Note</div><p>This guide assumes that the <code>&lt;path&gt;</code> parameter in your config.xml file is set to:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">&lt;path&gt;/var/lib/clickhouse/&lt;/path&gt;\n</code></pre></div><div class=\"activity_PoTP\"></div></div><p>If you have configured a different data path, replace all instances of <code>/var/lib/clickhouse</code> in the below commands with the actual value of your <code>&lt;path&gt;</code> setting.</p></div></div>\n<div class=\"sc-xro1ly-0 QlHdI vertical-stepper \"><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-0\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Copy access configuration from the healthy replica</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"copy-access-config\">Copy access configuration from the healthy replica<a href=\"https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure#copy-access-config\" class=\"hash-link\" aria-label=\"Direct link to Copy access configuration from the healthy replica\" title=\"Direct link to Copy access configuration from the healthy replica\">​</a></h2><p>Copy the contents of the <code>access</code> folder which contains local users from the healthy replica:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">/var/lib/clickhouse/access\n</code></pre></div><div class=\"activity_PoTP\"></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-1\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Back up the metadata folder from the healthy replica</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"back-up-the-metadata-folder-from-the-healthy-replica\">Back up the metadata folder from the healthy replica<a href=\"https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure#back-up-the-metadata-folder-from-the-healthy-replica\" class=\"hash-link\" aria-label=\"Direct link to Back up the metadata folder from the healthy replica\" title=\"Direct link to Back up the metadata folder from the healthy replica\">​</a></h2><ol class=\"custom-ol\">\n<li class=\"custom-li\">Navigate to the ClickHouse data directory:</li>\n</ol><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">cd /var/lib/clickhouse\n</code></pre></div><div class=\"activity_PoTP\"></div></div><ol class=\"custom-ol\" start=\"2\">\n<li class=\"custom-li\">Create a backup of the metadata folder (including symbolic links): The metadata directory contains DDLs for databases and tables.\nThe database directory has symlinks to <code>/var/lib/clickhouse/store/..</code> which contains all the table DDLs.</li>\n</ol><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-bash\"><code class=\"language-bash\">{ find metadata -type f; find metadata -type l; find metadata -type l | xargs readlink -f; } | tar -cPf backup.tar --files-from=-\n</code></pre></div><div class=\"activity_PoTP\"></div></div><div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Note</div><p>This command ensures that both the <strong>metadata files</strong>, and the symlink architecture are preserved in the backup.</p></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-2\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Restore the metadata on the faulty replica</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"restore-the-metadata-on-the-faulty-replica\">Restore the metadata on the faulty replica<a href=\"https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure#restore-the-metadata-on-the-faulty-replica\" class=\"hash-link\" aria-label=\"Direct link to Restore the metadata on the faulty replica\" title=\"Direct link to Restore the metadata on the faulty replica\">​</a></h2><ol class=\"custom-ol\">\n<li class=\"custom-li\">Copy the generated <code>backup.tar</code> file to the faulty replica.</li>\n<li class=\"custom-li\">Extract it to the ClickHouse data directory:</li>\n</ol><div class=\"wrapper_EBtA\" style=\"height:37.7px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">cd /var/lib/clickhouse/\ntar -xvPf backup.tar\n</code></pre></div><div class=\"activity_PoTP\"></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-3\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Create the force restore flag</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"create-force-restore-flag\">Create the force restore flag<a href=\"https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure#create-force-restore-flag\" class=\"hash-link\" aria-label=\"Direct link to Create the force restore flag\" title=\"Direct link to Create the force restore flag\">​</a></h2><p>To trigger automatic data synchronization from other replicas, create the following flag:</p><div class=\"wrapper_EBtA\" style=\"height:18.85px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data\n</code></pre></div><div class=\"activity_PoTP\"></div></div></div></div><div class=\"sc-xro1ly-1 bHdCRJ\"><button id=\"step-4\" class=\"sc-xro1ly-2 dOmWto\"><div class=\"sc-xro1ly-3 buAqWx\"></div><div class=\"sc-xro1ly-5 kxqSvA\">Restart the faulty replica</div></button><div class=\"sc-xro1ly-6 EHzUo\"><h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"restart-faulty-replica\">Restart the faulty replica<a href=\"https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure#restart-faulty-replica\" class=\"hash-link\" aria-label=\"Direct link to Restart the faulty replica\" title=\"Direct link to Restart the faulty replica\">​</a></h2><ol class=\"custom-ol\">\n<li class=\"custom-li\">Restart the ClickHouse server on the faulty node.</li>\n<li class=\"custom-li\">Check the server logs, you should observe parts being downloaded from the healthy replicas:</li>\n</ol><div class=\"wrapper_EBtA\" style=\"height:131.95000000000002px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-bash\"><code class=\"language-bash\">2025.11.02 00:00:04.047097 [ 682 ] {} &lt;Debug&gt; analytics.events_local (...) (Fetcher): Downloading files 23\n2025.11.02 00:00:04.055542 [ 682 ] {} &lt;Debug&gt; analytics.events_local (...) (Fetcher): Download of part 202511_0_0_0 onto disk disk2 finished.\n2025.11.02 00:00:04.101888 [ 687 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading part 2025_0_0_1 onto disk default.\n2025.11.02 00:00:04.102005 [ 687 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading files 11\n2025.11.02 00:00:04.102210 [ 690 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading part 2022_0_0_1 onto disk disk1.\n2025.11.02 00:00:04.102247 [ 688 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading part 2021_0_0_1 onto disk disk2.\n2025.11.02 00:00:04.102331 [ 690 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading files 11\n</code></pre></div><div class=\"activity_PoTP\"></div></div></div></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2025-11-19T00:00:00.000Z\">Nov 19, 2025</time> · <!-- -->2 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure",
            "title": "How to restore a replica after storage failure",
            "summary": "This article explains how to recover data when using replicated tables in atomic databases in ClickHouse and disks/storage on one of the replica is lost/currupted.",
            "date_modified": "2025-11-19T00:00:00.000Z",
            "tags": [
                "Deployments and Scaling"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/generate-har-file",
            "content_html": "A HAR (HTTP Archive) file captures the network activity in your browser. It can help our support team diagnose slow page loads, failed requests, or other network issues.<!-- -->\n<!-- -->\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"from-google-chrome\">From Google Chrome<a href=\"https://clickhouse.com/docs/knowledgebase/generate-har-file#from-google-chrome\" class=\"hash-link\" aria-label=\"Direct link to From Google Chrome\" title=\"Direct link to From Google Chrome\">​</a></h2>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">Open Developer Tools by pressing <kbd>F12</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>I</kbd> (Windows/Linux) / <kbd>Cmd</kbd> + <kbd>Option</kbd> + <kbd>I</kbd> (Mac).</li>\n<li class=\"custom-li\">Click the \"Network\" tab.</li>\n<li class=\"custom-li\">Reload the page and reproduce the issue.</li>\n<li class=\"custom-li\">From Developer Tools, click the download button.</li>\n</ol>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"from-mozilla-firefox\">From Mozilla Firefox<a href=\"https://clickhouse.com/docs/knowledgebase/generate-har-file#from-mozilla-firefox\" class=\"hash-link\" aria-label=\"Direct link to From Mozilla Firefox\" title=\"Direct link to From Mozilla Firefox\">​</a></h2>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">Open Developer Tools by pressing <kbd>F12</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>E</kbd> (Windows/Linux) / <kbd>Cmd</kbd> + <kbd>Option</kbd> + <kbd>E</kbd> (Mac).</li>\n<li class=\"custom-li\">Click the \"Network\" tab.</li>\n<li class=\"custom-li\">Reload the page and reproduce the issue.</li>\n<li class=\"custom-li\">From Developer Tools, right-click in the request list and select \"Save All As HAR\".</li>\n</ol>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"from-microsoft-edge\">From Microsoft Edge<a href=\"https://clickhouse.com/docs/knowledgebase/generate-har-file#from-microsoft-edge\" class=\"hash-link\" aria-label=\"Direct link to From Microsoft Edge\" title=\"Direct link to From Microsoft Edge\">​</a></h2>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">Open Developer Tools by pressing <kbd>F12</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>I</kbd> (Windows/Linux) / <kbd>Cmd</kbd> + <kbd>Option</kbd> + <kbd>I</kbd> (Mac).</li>\n<li class=\"custom-li\">Click the \"Network\" tab.</li>\n<li class=\"custom-li\">Reload the page and reproduce the issue.</li>\n<li class=\"custom-li\">From Developer Tools, right-click in the network list and choose \"Save all as HAR with content\".</li>\n</ol>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"from-safari\">From Safari<a href=\"https://clickhouse.com/docs/knowledgebase/generate-har-file#from-safari\" class=\"hash-link\" aria-label=\"Direct link to From Safari\" title=\"Direct link to From Safari\">​</a></h2>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">Enable Developer Tools (if not already enabled):<!-- -->\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">Go to Safari &gt; Settings &gt; Advanced.</li>\n<li class=\"custom-li\">Check \"Show Develop menu in menu bar\" at the bottom.</li>\n</ul>\n</li>\n<li class=\"custom-li\">Click Develop &gt; Show Web Inspector.</li>\n<li class=\"custom-li\">Click the \"Network\" tab.</li>\n<li class=\"custom-li\">Reload the page and reproduce the issue.</li>\n<li class=\"custom-li\">From Developer Tools, click the \"Export\" button.</li>\n</ol>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"sending-har-file\">Sending the .HAR file<a href=\"https://clickhouse.com/docs/knowledgebase/generate-har-file#sending-har-file\" class=\"hash-link\" aria-label=\"Direct link to Sending the .HAR file\" title=\"Direct link to Sending the .HAR file\">​</a></h2>\n<ol class=\"custom-ol\">\n<li class=\"custom-li\">Rename the file to something short and descriptive (e.g., login-issue.har).</li>\n<li class=\"custom-li\">Compress the file (optional but recommended).</li>\n<li class=\"custom-li\">Attach it to your support case or email it to your assigned support contact.</li>\n</ol>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Note</div><p>HAR files may contain session cookies or other sensitive data.\nOnly share them with authorized support personnel.</p></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2025-11-11T00:00:00.000Z\">Nov 11, 2025</time> · <!-- -->2 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/generate-har-file",
            "title": "How to Generate a HAR file for support",
            "summary": "A HAR (HTTP Archive) file captures the network activity in your browser. It can help our support team diagnose slow page loads, failed requests, or other network issues.",
            "date_modified": "2025-11-11T00:00:00.000Z",
            "tags": [
                "Tools and Utilities"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query",
            "content_html": "Troubleshooting memory limit exceeded errors for a query<!-- -->\n<!-- -->\n<!-- -->\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"troubleshooting-out-of-memory-issues\">Memory limit exceeded for query<a href=\"https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query#troubleshooting-out-of-memory-issues\" class=\"hash-link\" aria-label=\"Direct link to Memory limit exceeded for query\" title=\"Direct link to Memory limit exceeded for query\">​</a></h2>\n<p>As a new user, ClickHouse can often seem like magic - every query is super fast,\neven on the largest datasets and most ambitious queries. Invariably though,\nreal-world usage tests even the limits of ClickHouse. Queries exceeding memory\ncan be the result of a number of causes. Most commonly, we see large joins or\naggregations on high cardinality fields. If performance is critical, and these\nqueries are required, we often recommend users simply scale up - something\nClickHouse Cloud does automatically and effortlessly to ensure your queries\nremain responsive. We appreciate, however, that in self-managed scenarios,\nthis is sometimes not trivial, and maybe optimal performance is not even required.\nUsers, in this case, have a few options.</p>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"aggregations\">Aggregations<a href=\"https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query#aggregations\" class=\"hash-link\" aria-label=\"Direct link to Aggregations\" title=\"Direct link to Aggregations\">​</a></h3>\n<p>For memory-intensive aggregations or sorting scenarios, users can use the settings\n<a href=\"https://clickhouse.com/docs/operations/settings/settings#max_bytes_before_external_group_by\"><code>max_bytes_before_external_group_by</code></a>\nand <a href=\"https://clickhouse.com/docs/operations/settings/settings#max_bytes_ratio_before_external_sort\"><code>max_bytes_before_external_sort</code></a> respectively.\nThe former of which is discussed extensively <a href=\"https://clickhouse.com/docs/sql-reference/statements/select/group-by#group-by-in-external-memory\">here</a>.</p>\n<p>In summary, this ensures any aggregations can “spill” out to disk if a memory\nthreshold is exceeded. This will invariably impact query performance but will\nhelp ensure queries do not OOM. The latter sorting setting helps address similar\nissues with memory-intensive sorts. This can be particularly important in\ndistributed environments where a coordinating node receives sorted responses\nfrom child shards. In this case, the coordinating server can be asked to sort a\ndataset larger than its available memory. With <a href=\"https://clickhouse.com/docs/operations/settings/settings#max_bytes_ratio_before_external_sort\"><code>max_bytes_before_external_sort</code></a>,\nsorting can be allowed to spill over to disk. This setting is also helpful for\ncases where the user has an <code>ORDER BY</code> after a <code>GROUP BY</code> with a <code>LIMIT</code>,\nespecially in cases where the query is distributed.</p>\n<h3 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"joins\">Joins<a href=\"https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query#joins\" class=\"hash-link\" aria-label=\"Direct link to Joins\" title=\"Direct link to Joins\">​</a></h3>\n<p>For joins, users can select different <code>JOIN</code> algorithms, which can assist in\nlowering the required memory. By default, joins use the hash join, which offers\nthe most completeness with respect to features and often the best performance.\nThis algorithm loads the right-hand table of the <code>JOIN</code> into an in-memory hash\ntable, against which the left-hand table is then evaluated. To minimize memory,\nusers should thus place the smaller table on the right side. This approach still\nhas limitations in memory-bound cases, however. In these cases, <code>partial_merge</code>\njoin can be enabled via the <a href=\"https://clickhouse.com/docs/operations/settings/settings#join_algorithm\"><code>join_algorithm</code></a>\nsetting. This derivative of the <a href=\"https://en.wikipedia.org/wiki/Sort-merge_join\" target=\"_blank\" rel=\"noopener noreferrer\">sort-merge algorithm</a>,\nfirst sorts the right table into blocks and creates a min-max index for them.\nIt then sorts parts of the left table by the join key and joins them over the\nright table. The min-max index is used to skip unneeded right table blocks.\nThis is less memory-intensive at the expense of performance. Taking this concept\nfurther, the <code>full_sorting_merge</code> algorithm allows a <code>JOIN</code> to be performed when\nthe right-hand side is very large and doesn't fit into memory and lookups are\nimpossible, e.g. a complex subquery. In this case, both the right and left side\nare sorted on disk if they do not fit in memory, allowing large tables to be\njoined.</p>\n<div style=\"position:relative;margin-bottom:16px;margin-top:16px\"><div style=\"cursor:default\"><div style=\"background-size:cover;background-repeat:no-repeat;position:relative;background-image:url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAICAYAAADA+m62AAAACXBIWXMAAAsTAAALEwEAmpwYAAABO0lEQVR4nAXB3S5CAQDA8fMQtnCo2FBX0VZdmbJGNzbyEWutTh+k4tSWutEqLmo+xqW22lwgYcsOcsGY5UZb6QF6BO/w9/sJGs0wE7pxhtWDTE0ZcK558Xp92GwzxBMy5+dnSJIXIby1RTaTJhgM4pc8fDyk+Xx75Oq6Sqfd5va2Rr1eR0jI2xQPU4TDIVJJmb9ujp/vZy5KZbrdX2q1Go3GC4JWO8ToiBpRVGG3z5LYyxKJRrFap5HlHfL5HIGAhKDXT2A2m9HpxjAaDXjca8RiEZzORfw+N+FNHxvrKwinx0XuqhVOjo+Q5V0URaHZbFKpVPhSCnRek9xfHiDEoxLFfILNkJ9MZp9er0er1eKiVOK9XuDnaY+bcg5BFPsRxQFUqj4sFhMu1yrLy0s4HHOsL1rwr06yMG/iHyM8uOUuCkPAAAAAAElFTkSuQmCC&quot;);width:600px;margin:0 auto;display:block;box-shadow:none\"><svg style=\"width:100%;height:auto;max-width:100%;margin-bottom:-4px\" width=\"1024\" height=\"768\"></svg><noscript><img style=width:100%;height:auto;max-width:100%;margin-bottom:-4px;position:absolute;top:0;left:0 src=/docs/assets/ideal-img/memory-limit-exceeded-for-query.79cc359.48.png srcset=\"/docs/assets/ideal-img/memory-limit-exceeded-for-query.79cc359.48.png 48w,/docs/assets/ideal-img/memory-limit-exceeded-for-query.1b8b965.300.png 300w,/docs/assets/ideal-img/memory-limit-exceeded-for-query.23e1b2d.600.png 600w,/docs/assets/ideal-img/memory-limit-exceeded-for-query.7304bcc.1024.png 1024w\" alt=\"Joins algorithms\" width=1024 height=768></noscript></div></div></div>\n<p>Since 20.3, ClickHouse has supported an auto value for the <code>join_algorithm</code> setting.\nThis instructs ClickHouse to apply an adaptive join approach, where the hash-join\nalgorithm is preferred until memory limits are violated, at which point the\npartial_merge algorithm is attempted. Finally, concerning joins, we encourage\nreaders to be aware of the behavior of distributed joins and how to minimize\ntheir memory consumption. More information can be found <a href=\"https://clickhouse.com/docs/sql-reference/operators/in#distributed-subqueries\">here</a>.</p><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2025-07-25T00:00:00.000Z\">Jul 25, 2025</time> · <!-- -->3 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query",
            "title": "Memory limit exceeded for query",
            "summary": "Troubleshooting memory limit exceeded errors for a query",
            "date_modified": "2025-07-25T00:00:00.000Z",
            "tags": [
                "Errors and Exceptions"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/optimize_final_vs_final",
            "content_html": "Discusses the differences between OPTIMIZE FINAL and FINAL, and when to use and avoid them.<!-- -->\n<!-- -->\n<p><code>OPTIMIZE FINAL</code> is a DDL command that physically and permanently reorganizes\nand optimizes data on disk. It physically merges data parts in <code>MergeTree</code> tables,\nperforming data deduplication in the process by removing duplicate rows from storage.</p>\n<p><code>FINAL</code> is a <strong>query-time</strong> modifier that provides deduplicated results without\nchanging the structure of the stored data. It works by performing merge logic at\nread-time. It is temporary, only affecting the current query result.</p>\n<p>Users are often advised to avoid using <code>OPTIMIZE FINAL</code>, as it has a significant\nperformance overhead, however they should not confuse the two. It is often necessary\nto use <code>FINAL</code> to get back results without duplicates, especially when using table\nengines like <code>ReplacingMergeTree</code> which may contain duplicate rows which have not\nbeen replaced during the eventual, background merge process.</p>\n<p>The table below summarises the key differences:</p>\n<table><thead><tr><th>Aspect</th><th><code>OPTIMIZE FINAL</code></th><th><code>FINAL</code></th></tr></thead><tbody><tr><td>Type</td><td>DDL Command</td><td>Query Modifier</td></tr><tr><td>Effect</td><td>Permanent storage optimization</td><td>Temporary query-time deduplication</td></tr><tr><td>Performance</td><td>Impact\tHigh cost once, then faster queries</td><td>Lower individual cost, but repeated for each query</td></tr><tr><td>Data Modification</td><td>Yes - physically changes storage</td><td>No - read-only operation</td></tr><tr><td>Use Case</td><td>Periodic maintenance/optimization</td><td>Real-time deduplicated queries</td></tr></tbody></table>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"when-to-use-each\">When to use each<a href=\"https://clickhouse.com/docs/knowledgebase/optimize_final_vs_final#when-to-use-each\" class=\"hash-link\" aria-label=\"Direct link to When to use each\" title=\"Direct link to When to use each\">​</a></h2>\n<p>Use <code>OPTIMIZE FINAL</code> when:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">You want to permanently improve query performance</li>\n<li class=\"custom-li\">You can afford the one-time optimization cost</li>\n<li class=\"custom-li\">You're doing periodic table maintenance</li>\n<li class=\"custom-li\">You want to physically clean up duplicate data</li>\n</ul>\n<p>Use <code>FINAL</code> when:</p>\n<ul class=\"custom-ul\">\n<li class=\"custom-li\">You need deduplicated results immediately</li>\n<li class=\"custom-li\">You can't wait for or don't want permanent optimization</li>\n<li class=\"custom-li\">You only occasionally need deduplicated data</li>\n<li class=\"custom-li\">You're working with frequently changing data</li>\n</ul>\n<p>Both are valuable tools, but they serve different purposes in ClickHouse's deduplication strategy.</p><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2025-07-20T00:00:00.000Z\">Jul 20, 2025</time> · <!-- -->2 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/optimize_final_vs_final",
            "title": "What is the difference between OPTIMIZE FINAL and FINAL?",
            "summary": "Discusses the differences between OPTIMIZE FINAL and FINAL, and when to use and avoid them.",
            "date_modified": "2025-07-20T00:00:00.000Z",
            "tags": [
                "Core Data Concepts"
            ]
        },
        {
            "id": "https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance",
            "content_html": "Learn how to set up a custom DNS alias for your instance using a reverse proxy<!-- -->\n<!-- -->\n<br>\n<br>\n<blockquote>\n<p>In this knowledgebase article, we will walk you through how you can set up a\ncustom DNS alias for your ClickHouse Cloud instance through the use of a reverse\nproxy such as Nginx for ClickHouse native client.</p>\n</blockquote>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"create-certificate\">Create a self-signed certificate<a href=\"https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance#create-certificate\" class=\"hash-link\" aria-label=\"Direct link to Create a self-signed certificate\" title=\"Direct link to Create a self-signed certificate\">​</a></h2>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Note</div><p>This step is not needed if you are using signed certificates.</p></div></div>\n<p>Create a self-signed certificate with the domain name of your choice.\nIn this example we will use a domain name <code>xyz-customdomain.com</code> and\ncreate a certificate called <code>MyCertificate.crt</code>. Refer to <a href=\"https://clickhouse.com/docs/guides/sre/tls/configuring-tls#2-create-tls-certificates\">\"Create SSL certificates\"</a>\nfor further details.</p>\n<p>Add the certificate to <code>/etc/clickhouse-client/config.xml</code>:</p>\n<div class=\"wrapper_EBtA\" style=\"height:282.75px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-yaml\"><code class=\"language-yaml\">&lt;clickhouse&gt;\n    &lt;openSSL&gt;\n        &lt;client&gt;\n            &lt;loadDefaultCAFile&gt;false&lt;/loadDefaultCAFile&gt;\n            # highlight-next-line\n            &lt;caConfig&gt;/etc/ssl/certs/MyCertificate.crt&lt;/caConfig&gt;\n            &lt;cacheSessions&gt;true&lt;/cacheSessions&gt;\n            &lt;disableProtocols&gt;sslv2,sslv3&lt;/disableProtocols&gt;\n            &lt;preferServerCiphers&gt;true&lt;/preferServerCiphers&gt;\n            &lt;invalidCertificateHandler&gt;\n                &lt;name&gt;RejectCertificateHandler&lt;/name&gt;\n            &lt;/invalidCertificateHandler&gt;\n        &lt;/client&gt;\n    &lt;/openSSL&gt;\n&lt;/clickhouse&gt;\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"update-nginx-config\">Update Nginx configuration<a href=\"https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance#update-nginx-config\" class=\"hash-link\" aria-label=\"Direct link to Update Nginx configuration\" title=\"Direct link to Update Nginx configuration\">​</a></h2>\n<p>Add the following in your <code>nginx.conf</code> file:</p>\n<div class=\"wrapper_EBtA\" style=\"height:37.7px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">proxy_ssl_name xyz.us-west-2.aws.clickhouse.cloud;\nproxy_ssl_server_name on;\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<div class=\"wrapper_EBtA\" style=\"height:490.1px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">stream {\n    upstream stream_backend {\n         server xyz.us-west-2.aws.clickhouse.cloud:9440;\n    }\n\n    server {\n        listen                9440 ssl;\n        proxy_pass            stream_backend;\n\n        ssl_certificate       /etc/ssl/certs/MyCertificate.crt;\n        ssl_certificate_key   /etc/ssl/certs/MyKey.key;\n        ssl_protocols         SSLv3 TLSv1 TLSv1.1 TLSv1.2;\n        ssl_ciphers           HIGH:!aNULL:!MD5;\n        ssl_session_cache     shared:SSL:20m;\n        ssl_session_timeout   4h;\n        ssl_handshake_timeout 30s;\n\tproxy_ssl on;\n\tproxy_ssl_trusted_certificate /etc/ssl/certs/isrgrootx1.pem;\n\tproxy_ssl_session_reuse on;\n        proxy_ssl_verify on;\n    #highlight-next-line\n\tproxy_ssl_name xyz.us-west-2.aws.clickhouse.cloud;\n    #highlight-next-line\n\tproxy_ssl_server_name on;\n    }\n}\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>Where <code>isrgrootx1.pem</code> is the root certificate for ClickHouse Cloud which you\ncan download <a href=\"https://letsencrypt.org/certs/isrgrootx1.pem\" target=\"_blank\" rel=\"noopener noreferrer\">here</a>.</p>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"update-hosts-file\">Update hosts file<a href=\"https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance#update-hosts-file\" class=\"hash-link\" aria-label=\"Direct link to Update hosts file\" title=\"Direct link to Update hosts file\">​</a></h2>\n<div class=\"theme-admonition theme-admonition-note alert alert--secondary admonition_WoCw\"><div class=\"alert-icon admonitionIcon_Ibzs\"><svg viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z\"></path></svg></div><div class=\"alert-content admonitionContent_vXIg\"><div class=\"admonitionHeading_TMsN\">Note</div><p>The following step is not needed if you are using your own domain controllers</p></div></div>\n<p>Add the following to your <code>/etc/hosts</code> file on the Nginx server:</p>\n<div class=\"wrapper_EBtA\" style=\"height:56.550000000000004px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-text\"><code class=\"language-text\">127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4\n::1         localhost6 localhost6.localdomain6\n10.X.Y.Z  xyz-customdomain.com\n</code></pre></div><div class=\"activity_PoTP\"></div></div>\n<p>Where <code>10.X.Y.Z</code> is the IP address of your specific Nginx box.</p>\n<h2 class=\"anchor anchorWithStickyNavbar_LWe7\" id=\"connect-to-cloud-using-alias\">Connect to Cloud using alias<a href=\"https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance#connect-to-cloud-using-alias\" class=\"hash-link\" aria-label=\"Direct link to Connect to Cloud using alias\" title=\"Direct link to Connect to Cloud using alias\">​</a></h2>\n<p>You are now ready to connect using your custom alias:</p>\n<div class=\"wrapper_EBtA\" style=\"height:113.10000000000001px\"><div style=\"position:absolute;left:-9999px;top:-9999px;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden\"><pre class=\"language-bash\"><code class=\"language-bash\">clickhouse-client --host xyz.customdomain.com --secure --password 'xxxxxxx'\nClickHouse client version 23.12.1.428 (official build).\nConnecting to xyz.customdomain.com:9440 as user default.\nConnected to ClickHouse server version 23.9.2.\n\nclickhouse-cloud :)\n</code></pre></div><div class=\"activity_PoTP\"></div></div><div class=\"container_iJTo margin-vert--md\"><time datetime=\"2025-05-16T00:00:00.000Z\">May 16, 2025</time> · <!-- -->2 min read</div>",
            "url": "https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance",
            "title": "Create a custom DNS alias by setting up a reverse proxy",
            "summary": "Learn how to set up a custom DNS alias for your instance using a reverse proxy",
            "date_modified": "2025-05-16T00:00:00.000Z",
            "tags": [
                "Server Admin",
                "Security and Authentication"
            ]
        }
    ]
}