<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://clickhouse.com/docs/knowledgebase</id>
    <title>ClickHouse Knowledge Base Feed</title>
    <updated>2026-02-10T21:35:36.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://clickhouse.com/docs/knowledgebase"/>
    <subtitle>Feed of articles posted to the ClickHouse Knowledge Base</subtitle>
    <icon>https://clickhouse.com/docs/img/docs_favicon.ico</icon>
    <rights>Copyright &amp;copy; 2016&amp;ndash;2026 ClickHouse, Inc. ClickHouse Docs provided under the Creative Commons CC BY-NC-SA 4.0 license. ClickHouse&amp;reg; is a registered trademark of ClickHouse, Inc.</rights>
    <entry>
        <title type="html"><![CDATA[Terraform example on how to use Cloud API]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/terraform_example</id>
        <link href="https://clickhouse.com/docs/knowledgebase/terraform_example"/>
        <updated>2026-02-10T21:35:36.000Z</updated>
        <summary type="html"><![CDATA[This covers an example of how you can use terraform to create/delete clusters using the API]]></summary>
        <content type="html"><![CDATA[This covers an example of how you can use terraform to create/delete clusters using the API<!-- -->
<!-- -->
<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>
<p>How can I use API to manage clusters on ClickHouse Cloud?</p>
<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>
<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>
<p>Steps:</p>
<p>1). Create an API Key on Cloud.
Follow 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>
<p>Save the creds locally.</p>
<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>
<p>You can use Homebrew package manager if you're on Mac.</p>
<p>3). Create a directory anywhere you like:</p>
<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
➜  test pwd
/Users/jaijhala/Desktop/terraform/test
</code></pre></div><div class="activity_PoTP"></div></div>
<p>4). Create 2 files: <code>main.tf</code> and <code>secret.tfvars</code></p>
<p>Copy the following:</p>
<p><code>main.tf</code> file would be:</p>
<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 {
 required_providers {
   clickhouse = {
     source = "ClickHouse/clickhouse"
     version = "0.0.2"
   }
 }
}

variable "organization_id" {
  type = string
}

variable "token_key" {
  type = string
}

variable "token_secret" {
  type = string
}

provider clickhouse {
  environment 	= "production"
  organization_id = var.organization_id
  token_key   	= var.token_key
  token_secret	= var.token_secret
}


variable "service_password" {
  type = string
  sensitive   = true
}

resource "clickhouse_service" "service123" {
  name       	= "jai-terraform"
  cloud_provider = "aws"
  region     	= "us-east-2"
  tier       	= "development"
  idle_scaling   = true
  password  = var.service_password
  ip_access = [
	{
    	source  	= "0.0.0.0/0"
    	description = "Anywhere"
	}
  ]
}

output "CLICKHOUSE_HOST" {
  value = clickhouse_service.service123.endpoints.0.host
}
</code></pre></div><div class="activity_PoTP"></div></div>
<p>You can replace your own parameters like service name, region etc.. in the resources section above.</p>
<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>
<p>It would be something like (replace these parameters):</p>
<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"
token_key = "QWhhkMeytqQruTeKg"
token_secret = "4b1dNmjWdLUno9lXxmKvSUcPP62jvn7irkuZPbY"
service_password = "password123!"
</code></pre></div><div class="activity_PoTP"></div></div>
<p>5).  Run <code>terraform init</code> from this directory</p>
<p>Expected output:</p>
<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...

Initializing provider plugins...
- Finding clickhouse/clickhouse versions matching "0.0.2"...
- Installing clickhouse/clickhouse v0.0.2...
- Installed clickhouse/clickhouse v0.0.2 (self-signed, key ID D7089EE5C6A92ED1)

Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
</code></pre></div><div class="activity_PoTP"></div></div>
<p>6). Run <code>terraform apply -var-file=secret.tfvars</code> command.</p>
<p>Something like:</p>
<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

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
  + create

Terraform will perform the following actions:

  # clickhouse_service.service123 will be created
  + resource "clickhouse_service" "service123" {
      + cloud_provider = "aws"
      + endpoints      = (known after apply)
      + id             = (known after apply)
      + idle_scaling   = true
      + ip_access      = [
          + {
              + description = "Anywhere"
              + source      = "0.0.0.0/0"
            },
        ]
      + last_updated   = (known after apply)
      + name           = "jai-terraform"
      + password       = (sensitive value)
      + region         = "us-east-2"
      + tier           = "development"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + CLICKHOUSE_HOST = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes
</code></pre></div><div class="activity_PoTP"></div></div>
<p>Type <code>yes</code> and hit enter</p>
<p>Side note: Notice it says <code>password       = (sensitive value)</code> above.
This is because we set <code>sensitive   = true</code> for the password in the main.tf file.</p>
<p>7). It will take a couple of mins to create the service but eventually it should come up like:</p>
<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

clickhouse_service.service123: Creating...
clickhouse_service.service123: Still creating... [10s elapsed]
clickhouse_service.service123: Still creating... [20s elapsed]
clickhouse_service.service123: Still creating... [30s elapsed]
clickhouse_service.service123: Still creating... [40s elapsed]
clickhouse_service.service123: Still creating... [50s elapsed]
clickhouse_service.service123: Still creating... [1m0s elapsed]
clickhouse_service.service123: Still creating... [1m10s elapsed]
clickhouse_service.service123: Still creating... [1m20s elapsed]
clickhouse_service.service123: Still creating... [1m30s elapsed]
clickhouse_service.service123: Still creating... [1m40s elapsed]
clickhouse_service.service123: Creation complete after 1m41s [id=aa8d8d63-1878-4600-8470-630715af38ed]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

CLICKHOUSE_HOST = "h3ljlaqez6.us-east-2.aws.clickhouse.cloud"
➜  test
</code></pre></div><div class="activity_PoTP"></div></div>
<p>8). Check Cloud Console, you should be able to see the service created.</p>
<p>9). To clean up/destroy the service again, run <code>terraform destroy -var-file=secret.tfvars</code></p>
<p>Something like:</p>
<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
the following symbols:
  - destroy

Terraform will perform the following actions:

  # clickhouse_service.service123 will be destroyed
  - resource "clickhouse_service" "service123" {
      - cloud_provider = "aws" -&gt; null
      - ............

Plan: 0 to add, 0 to change, 1 to destroy.

Changes to Outputs:
  - CLICKHOUSE_HOST = "h3ljlaqez6.us-east-2.aws.clickhouse.cloud" -&gt; null

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value:
</code></pre></div><div class="activity_PoTP"></div></div>
<p>Type yes and hit enter</p>
<p>10).</p>
<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]
clickhouse_service.service123: Still destroying... [id=aa8d8d63-1878-4600-8470-630715af38ed, 10s elapsed]
clickhouse_service.service123: Still destroying... [id=aa8d8d63-1878-4600-8470-630715af38ed, 20s elapsed]
clickhouse_service.service123: Destruction complete after 27s

Destroy complete! Resources: 1 destroyed.
</code></pre></div><div class="activity_PoTP"></div></div>
<p>And it should be gone from the Cloud Console.</p>
<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-10T21:35:36.000Z">Feb 10, 2026</time> · <!-- -->5 min read</div>]]></content>
        <category label="Native Clients and Interfaces" term="Native Clients and Interfaces"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[How to opt out of core dump collection]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection</id>
        <link href="https://clickhouse.com/docs/knowledgebase/opt-out-core-dump-collection"/>
        <updated>2026-02-04T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[This article shows you how you can opt out of core dump collection on ClickHouse Cloud]]></summary>
        <content type="html"><![CDATA[This article shows you how you can opt out of core dump collection on ClickHouse Cloud<!-- -->
<!-- -->
<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>
<p>Starting <strong>February 27, 2026</strong>, ClickHouse Cloud will begin collecting core dumps when server crashes occur. This is part of our commitment to improving service reliability for all our users.</p>
<p>Core dump collection helps us:</p>
<ul class="custom-ul">
<li class="custom-li">Identify and understand what caused a crash</li>
<li class="custom-li">Fix issues more quickly</li>
<li class="custom-li">Continuously improve your service experience</li>
</ul>
<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>
<p>When a crash occurs, core dumps 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>
<ul class="custom-ul">
<li class="custom-li">Connection credentials</li>
<li class="custom-li">Encryption keys</li>
<li class="custom-li">Query strings</li>
<li class="custom-li">Other data in memory at the time of the crash</li>
</ul>
<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>
<p>We take the security of this data seriously:</p>
<ul class="custom-ul">
<li class="custom-li"><strong>Regional Storage</strong>: All data stays in the same region as your service</li>
<li class="custom-li"><strong>Enhanced Security</strong>: We apply additional protections to all collected data</li>
<li class="custom-li"><strong>Limited Retention</strong>: Data is kept only as long as needed for debugging, then securely deleted</li>
</ul>
<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>
<p>Some services are automatically excluded from core dump collection:</p>
<ul class="custom-ul">
<li class="custom-li">Services with <strong>HIPAA</strong> compliance requirements</li>
<li class="custom-li">Services with <strong>PCI</strong> compliance requirements</li>
<li class="custom-li"><strong>BYOC</strong> (Bring Your Own Cloud) services</li>
</ul>
<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>
<p>If you'd prefer not to participate in core dump collection, you can easily opt out:</p>
<ol class="custom-ol">
<li class="custom-li">Go to the <a href="https://clickhouse.cloud/" target="_blank" rel="noopener noreferrer">ClickHouse Cloud Console</a></li>
<li class="custom-li">Select your service</li>
<li class="custom-li">Click on the <strong>Settings</strong> tab</li>
<li class="custom-li">Scroll to find "Share crash reports with ClickHouse"</li>
<li class="custom-li">Toggle the option off to opt out</li>
</ol>
<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><div class="container_iJTo margin-vert--md"><time datetime="2026-02-04T00:00:00.000Z">Feb 4, 2026</time> · <!-- -->2 min read</div>]]></content>
        <category label="Managing Cloud" term="Managing Cloud"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Understanding part types and storage formats]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats</id>
        <link href="https://clickhouse.com/docs/knowledgebase/understanding-part-types-and-storage-formats"/>
        <updated>2026-02-03T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Learn about the different part types (Wide vs Compact) and storage formats (Full vs Packed) in ClickHouse, and how they affect performance.]]></summary>
        <content type="html"><![CDATA[Learn about the different part types (Wide vs Compact) and storage formats (Full vs Packed) in ClickHouse, and how they affect performance.<!-- -->
<!-- -->
<br>
<br>
<p>ClickHouse uses two independent concepts for organizing data within parts:</p>
<ul class="custom-ul">
<li class="custom-li"><strong>Part types</strong> (Wide vs Compact): How column data is stored within a part</li>
<li class="custom-li"><strong>Storage formats</strong> (Full vs Packed): How the part's files are stored on disk</li>
</ul>
<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>
<p>Part types determine how column data is organized within a data part.</p>
<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>
<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>
<p>The part type is controlled by the following table settings:</p>
<ul class="custom-ul">
<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>
<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>
</ul>
<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>
<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>
<p><strong>Compact parts:</strong></p>
<ul class="custom-ul">
<li class="custom-li">Better ingestion performance</li>
<li class="custom-li">Optimal when queries need all columns</li>
<li class="custom-li">More efficient for small parts</li>
</ul>
<p><strong>Wide parts:</strong></p>
<ul class="custom-ul">
<li class="custom-li">More efficient for queries selecting only a subset of columns</li>
<li class="custom-li">Better for large datasets with selective column access</li>
</ul>
<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>
<p>This can be useful in the following scenarios:</p>
<ol class="custom-ol">
<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>
<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>
<li class="custom-li">When dealing with tables that have high insert volumes and you want to optimize storage and merge behavior</li>
<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>
</ol>
<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>
<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>
<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>
<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>
<p>Storage formats determine how a part's files are physically stored on disk.</p>
<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>
<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>
<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>
<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>
<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>
<p><strong>Benefits of Packed storage:</strong></p>
<ul class="custom-ul">
<li class="custom-li">Fewer S3/object storage API calls</li>
<li class="custom-li">Reduced metadata pressure on the coordination service</li>
<li class="custom-li">Lower storage costs (full storage can be significantly more expensive)</li>
<li class="custom-li">Better performance for small parts on remote storage</li>
</ul>
<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>
<p>In ClickHouse Cloud, a part uses Packed storage if <strong>any</strong> of these conditions are true:</p>
<ul class="custom-ul">
<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>
<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>
<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>
</ul>
<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>
<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.
The 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>
<p>Changing it from the default value (0) could be considered in the following use cases:</p>
<ul class="custom-ul">
<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>
<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>
<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>
</ul>
<p>Recommended configuration:</p>
<p>Set <code>min_level_for_full_part_storage = 2</code> for cloud deployments.
This ensures that:</p>
<ul class="custom-ul">
<li class="custom-li">Level 0 parts (initial inserts) use packed storage</li>
<li class="custom-li">Level 1 parts continue using packed storage</li>
<li class="custom-li">Only parts at level 2 and above use full storage format</li>
</ul>
<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>
<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>
<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>
<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>
<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>
<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>
<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
    part_type,
    part_storage_type,
    max(level),
    count(),
    formatReadableSize(max(data_uncompressed_bytes)),
    formatReadableSize(min(data_uncompressed_bytes))
FROM system.parts
WHERE (database != 'system') AND active
GROUP BY
    1,
    2
ORDER BY
    1 ASC,
    2 ASC
</code></pre></div><div class="activity_PoTP"></div></div>
<p>You will see something like this:</p>
<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))─┐
1. │ Compact   │ Full              │      12688 │    2456 │ 1023.87 MiB              │ 23.78 MiB                │
2. │ Compact   │ Packed            │      97383 │   13748 │ 127.77 MiB               │ 1.00 B                   │
3. │ Wide      │ Full              │       7642 │    2000 │ 1.38 TiB                 │ 30.18 MiB                │
4. │ Wide      │ Packed            │         10 │     187 │ 110.01 MiB               │ 1.30 KiB                 │
   └───────────┴───────────────────┴────────────┴─────────┴──────────────────────────┴──────────────────────────┘
</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>]]></content>
        <category label="Core Data Concepts" term="Core Data Concepts"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Find counts and sizes of wide or compact parts]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/count-parts-by-type</id>
        <link href="https://clickhouse.com/docs/knowledgebase/count-parts-by-type"/>
        <updated>2026-01-12T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[This knowledgebase article shows you how to find part counts by the type of part - wide or compact.]]></summary>
        <content type="html"><![CDATA[This knowledgebase article shows you how to find part counts by the type of part - wide or compact.<!-- -->
<!-- -->
<br>
<p>The following query can be used to count the number of parts by type:</p>
<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
    table,
    part_type,
    count(*)
FROM system.parts
WHERE active
GROUP BY
    table,
    part_type
ORDER BY
    table ASC,
    part_type ASC
</code></pre></div><div class="activity_PoTP"></div></div>
<p>An example response is shown below:</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-response"><code class="language-response">┌─table───────────────────┬─part_type─┬─count()─┐
│ asynchronous_metric_log │ Compact   │       6 │
│ metric_log              │ Compact   │       1 │
│ otel_logs               │ Compact   │       5 │
│ otel_logs               │ Wide      │       2 │
│ part_log                │ Compact   │       2 │
│ query_log               │ Compact   │       5 │
│ session_log             │ Compact   │       2 │
│ text_log                │ Compact   │       7 │
│ trace_log               │ Compact   │       6 │
└─────────────────────────┴───────────┴─────────┘
</code></pre></div><div class="activity_PoTP"></div></div>
<p>Run the query below to query part size for wide and compact parts:</p>
<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
    table,
    column,
    part_type,
    sum(rows),
    sum(column_data_compressed_bytes),
    sum(column_data_uncompressed_bytes)
FROM system.parts_columns
WHERE active
GROUP BY
    table,
    column,
    part_type
ORDER BY
    table ASC,
    column ASC,
    part_type ASC
</code></pre></div><div class="activity_PoTP"></div></div>
<p>An example response is shown below:</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-response"><code class="language-response">┌─table─────┬─column─────────────┬─part_type─┬─sum(rows)─┬─sum(column_data_compressed_bytes)─┬─sum(column_data_uncompressed_bytes)─┐
│ otel_logs │ Body               │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ Body               │ Wide      │  18900157 │                         316784170 │                          2807508947 │
│ otel_logs │ LogAttributes      │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ LogAttributes      │ Wide      │  18900157 │                         215812392 │                          3173566494 │
│ otel_logs │ ResourceAttributes │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ ResourceAttributes │ Wide      │  18900157 │                          94428129 │                          2258154988 │
│ otel_logs │ ServiceName        │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ ServiceName        │ Wide      │  18900157 │                             24726 │                            18973727 │
│ otel_logs │ SeverityNumber     │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ SeverityNumber     │ Wide      │  18900157 │                             51973 │                            75600628 │
│ otel_logs │ SeverityText       │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ SeverityText       │ Wide      │  18900157 │                             24726 │                            18973727 │
│ otel_logs │ SpanId             │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ SpanId             │ Wide      │  18900157 │                             13048 │                            18900157 │
│ otel_logs │ Timestamp          │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ Timestamp          │ Wide      │  18900157 │                          61225801 │                           151201256 │
│ otel_logs │ TraceFlags         │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ TraceFlags         │ Wide      │  18900157 │                             51973 │                            75600628 │
│ otel_logs │ TraceId            │ Compact   │   1564357 │                                 0 │                                   0 │
│ otel_logs │ TraceId            │ Wide      │  18900157 │                             13048 │                            18900157 │
└───────────┴────────────────────┴───────────┴───────────┴───────────────────────────────────┴─────────────────────────────────────┘
</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">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>]]></content>
        <category label="Troubleshooting" term="Troubleshooting"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[How to collect and draw a query trace]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces</id>
        <link href="https://clickhouse.com/docs/knowledgebase/collect-and-draw-traces"/>
        <updated>2025-12-30T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[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.]]></summary>
        <content type="html"><![CDATA[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.<!-- -->
<!-- -->
<br>
<br>
<p><strong>Prerequisites</strong>:</p>
<ul class="custom-ul">
<li class="custom-li">Familiarity with ClickHouse <a href="https://clickhouse.com/docs/operations/configuration-files">config files</a></li>
<li class="custom-li">A running instance of <a href="https://clickhouse.com/docs/install">ClickHouse server</a></li>
<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>
</ul>
<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;!--
    OpenTelemetry log contains OpenTelemetry trace spans.

    NOTE: this table does not use standard schema with event_date and event_time!
--&gt;
&lt;opentelemetry_span_log&gt;
    &lt;!--
        The default table creation code is insufficient, this &lt;engine&gt; spec
        is a workaround. There is no 'event_time' for this log, but two times,
        start and finish. It is sorted by finish time, to avoid inserting
        data too far away in the past (probably we can sometimes insert a span
        that is seconds earlier than the last span in the table, due to a race
        between several spans inserted in parallel). This gives the spans a
        global order that we can use to e.g. retry insertion into some external
        system.
    --&gt;
    &lt;engine&gt;
        engine MergeTree
        partition by toYYYYMM(finish_date)
        order by (finish_date, finish_time_us, trace_id)
    &lt;/engine&gt;
    &lt;database&gt;system&lt;/database&gt;
    &lt;table&gt;opentelemetry_span_log&lt;/table&gt;
    &lt;flush_interval_milliseconds&gt;7500&lt;/flush_interval_milliseconds&gt;
    &lt;max_size_rows&gt;1048576&lt;/max_size_rows&gt;
    &lt;reserved_size_rows&gt;8192&lt;/reserved_size_rows&gt;
    &lt;buffer_size_rows_flush_threshold&gt;524288&lt;/buffer_size_rows_flush_threshold&gt;
    &lt;flush_on_crash&gt;false&lt;/flush_on_crash&gt;
&lt;/opentelemetry_span_log&gt;
</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.
This 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'.
There is no file 'config.xml', will use embedded config.
</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;
</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
</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;
</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
<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);
</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);

SELECT pow(number, 2)
FROM numbers(100000.)

--highlight-next-line
Query id: a9241258-a0c4-4776-a00b-e6a1d9bec4a1
</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
SELECT
    concat(substring(hostName(), length(hostName()), 1), leftPad(greatest(attribute['clickhouse.thread_id'], attribute['thread_number']), 5, '0')) AS group,
    operation_name,
    start_time_us,
    finish_time_us,
    sipHash64(operation_name) AS color,
    attribute
FROM system.opentelemetry_span_log
WHERE (trace_id IN (
    SELECT trace_id
    FROM system.opentelemetry_span_log
    WHERE (attribute['clickhouse.query_id']) = my_query_id
)) AND (operation_name != 'query') AND (operation_name NOT LIKE 'Query%')
ORDER BY
    hostName() ASC,
    group ASC,
    parent_span_id ASC,
    start_time_us ASC
INTO OUTFILE 'trace.json'
FORMAT JSON
SETTINGS output_format_json_named_tuples_as_objects = 1
</code></pre></div><div class="activity_PoTP"></div></div><p>This will write the trace to a file named <code>trace.json</code>.
By 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>.
Load 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.
The plugin has been enhanced to allow visualization of traces using the Trace Panel.
This 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>
to 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
    toString(trace_id) AS traceID,
    toString(span_id) AS spanID,
    if(toString(parent_span_id)='0', '', toString(parent_span_id)) AS parentSpanID,
    'ClickHouse' AS serviceName,
    operation_name AS operationName,
    start_time_us/1000000 AS startTime,
    (finish_time_us - start_time_us)/1000 AS duration,
    arrayMap(key -&gt; map('key', key, 'value', attribute[key]), mapKeys(attribute)) AS serviceTags
FROM system.opentelemetry_span_log
WHERE trace_id = '68a14b27-a61f-596d-3746-2b03d2530e42' ORDER BY startTime ASC
</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>]]></content>
        <category label="Tools and Utilities" term="Tools and Utilities"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[How to restore a replica after storage failure]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure</id>
        <link href="https://clickhouse.com/docs/knowledgebase/restore-replica-after-storage-failure"/>
        <updated>2025-11-19T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[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.]]></summary>
        <content type="html"><![CDATA[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.<!-- -->
<!-- -->
<br>
<br>
<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;
</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>
<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
</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">
<li class="custom-li">Navigate to the ClickHouse data directory:</li>
</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
</code></pre></div><div class="activity_PoTP"></div></div><ol class="custom-ol" start="2">
<li class="custom-li">Create a backup of the metadata folder (including symbolic links): The metadata directory contains DDLs for databases and tables.
The database directory has symlinks to <code>/var/lib/clickhouse/store/..</code> which contains all the table DDLs.</li>
</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=-
</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">
<li class="custom-li">Copy the generated <code>backup.tar</code> file to the faulty replica.</li>
<li class="custom-li">Extract it to the ClickHouse data directory:</li>
</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/
tar -xvPf backup.tar
</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
</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">
<li class="custom-li">Restart the ClickHouse server on the faulty node.</li>
<li class="custom-li">Check the server logs, you should observe parts being downloaded from the healthy replicas:</li>
</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
2025.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.
2025.11.02 00:00:04.101888 [ 687 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading part 2025_0_0_1 onto disk default.
2025.11.02 00:00:04.102005 [ 687 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading files 11
2025.11.02 00:00:04.102210 [ 690 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading part 2022_0_0_1 onto disk disk1.
2025.11.02 00:00:04.102247 [ 688 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading part 2021_0_0_1 onto disk disk2.
2025.11.02 00:00:04.102331 [ 690 ] {} &lt;Debug&gt; warehouse.customers_local (...) (Fetcher): Downloading files 11
</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>]]></content>
        <category label="Deployments and Scaling" term="Deployments and Scaling"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[How to Generate a HAR file for support]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/generate-har-file</id>
        <link href="https://clickhouse.com/docs/knowledgebase/generate-har-file"/>
        <updated>2025-11-11T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[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.]]></summary>
        <content type="html"><![CDATA[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.<!-- -->
<!-- -->
<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>
<ol class="custom-ol">
<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>
<li class="custom-li">Click the "Network" tab.</li>
<li class="custom-li">Reload the page and reproduce the issue.</li>
<li class="custom-li">From Developer Tools, click the download button.</li>
</ol>
<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>
<ol class="custom-ol">
<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>
<li class="custom-li">Click the "Network" tab.</li>
<li class="custom-li">Reload the page and reproduce the issue.</li>
<li class="custom-li">From Developer Tools, right-click in the request list and select "Save All As HAR".</li>
</ol>
<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>
<ol class="custom-ol">
<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>
<li class="custom-li">Click the "Network" tab.</li>
<li class="custom-li">Reload the page and reproduce the issue.</li>
<li class="custom-li">From Developer Tools, right-click in the network list and choose "Save all as HAR with content".</li>
</ol>
<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>
<ol class="custom-ol">
<li class="custom-li">Enable Developer Tools (if not already enabled):<!-- -->
<ul class="custom-ul">
<li class="custom-li">Go to Safari &gt; Settings &gt; Advanced.</li>
<li class="custom-li">Check "Show Develop menu in menu bar" at the bottom.</li>
</ul>
</li>
<li class="custom-li">Click Develop &gt; Show Web Inspector.</li>
<li class="custom-li">Click the "Network" tab.</li>
<li class="custom-li">Reload the page and reproduce the issue.</li>
<li class="custom-li">From Developer Tools, click the "Export" button.</li>
</ol>
<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>
<ol class="custom-ol">
<li class="custom-li">Rename the file to something short and descriptive (e.g., login-issue.har).</li>
<li class="custom-li">Compress the file (optional but recommended).</li>
<li class="custom-li">Attach it to your support case or email it to your assigned support contact.</li>
</ol>
<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.
Only 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>]]></content>
        <category label="Tools and Utilities" term="Tools and Utilities"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Memory limit exceeded for query]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query</id>
        <link href="https://clickhouse.com/docs/knowledgebase/memory-limit-exceeded-for-query"/>
        <updated>2025-07-25T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Troubleshooting memory limit exceeded errors for a query]]></summary>
        <content type="html"><![CDATA[Troubleshooting memory limit exceeded errors for a query<!-- -->
<!-- -->
<!-- -->
<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>
<p>As a new user, ClickHouse can often seem like magic - every query is super fast,
even on the largest datasets and most ambitious queries. Invariably though,
real-world usage tests even the limits of ClickHouse. Queries exceeding memory
can be the result of a number of causes. Most commonly, we see large joins or
aggregations on high cardinality fields. If performance is critical, and these
queries are required, we often recommend users simply scale up - something
ClickHouse Cloud does automatically and effortlessly to ensure your queries
remain responsive. We appreciate, however, that in self-managed scenarios,
this is sometimes not trivial, and maybe optimal performance is not even required.
Users, in this case, have a few options.</p>
<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>
<p>For memory-intensive aggregations or sorting scenarios, users can use the settings
<a href="https://clickhouse.com/docs/operations/settings/settings#max_bytes_before_external_group_by"><code>max_bytes_before_external_group_by</code></a>
and <a href="https://clickhouse.com/docs/operations/settings/settings#max_bytes_ratio_before_external_sort"><code>max_bytes_before_external_sort</code></a> respectively.
The 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>
<p>In summary, this ensures any aggregations can “spill” out to disk if a memory
threshold is exceeded. This will invariably impact query performance but will
help ensure queries do not OOM. The latter sorting setting helps address similar
issues with memory-intensive sorts. This can be particularly important in
distributed environments where a coordinating node receives sorted responses
from child shards. In this case, the coordinating server can be asked to sort a
dataset 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>,
sorting can be allowed to spill over to disk. This setting is also helpful for
cases where the user has an <code>ORDER BY</code> after a <code>GROUP BY</code> with a <code>LIMIT</code>,
especially in cases where the query is distributed.</p>
<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>
<p>For joins, users can select different <code>JOIN</code> algorithms, which can assist in
lowering the required memory. By default, joins use the hash join, which offers
the most completeness with respect to features and often the best performance.
This algorithm loads the right-hand table of the <code>JOIN</code> into an in-memory hash
table, against which the left-hand table is then evaluated. To minimize memory,
users should thus place the smaller table on the right side. This approach still
has limitations in memory-bound cases, however. In these cases, <code>partial_merge</code>
join can be enabled via the <a href="https://clickhouse.com/docs/operations/settings/settings#join_algorithm"><code>join_algorithm</code></a>
setting. This derivative of the <a href="https://en.wikipedia.org/wiki/Sort-merge_join" target="_blank" rel="noopener noreferrer">sort-merge algorithm</a>,
first sorts the right table into blocks and creates a min-max index for them.
It then sorts parts of the left table by the join key and joins them over the
right table. The min-max index is used to skip unneeded right table blocks.
This is less memory-intensive at the expense of performance. Taking this concept
further, the <code>full_sorting_merge</code> algorithm allows a <code>JOIN</code> to be performed when
the right-hand side is very large and doesn't fit into memory and lookups are
impossible, e.g. a complex subquery. In this case, both the right and left side
are sorted on disk if they do not fit in memory, allowing large tables to be
joined.</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,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>
<p>Since 20.3, ClickHouse has supported an auto value for the <code>join_algorithm</code> setting.
This instructs ClickHouse to apply an adaptive join approach, where the hash-join
algorithm is preferred until memory limits are violated, at which point the
partial_merge algorithm is attempted. Finally, concerning joins, we encourage
readers to be aware of the behavior of distributed joins and how to minimize
their 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>]]></content>
        <category label="Errors and Exceptions" term="Errors and Exceptions"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[What is the difference between OPTIMIZE FINAL and FINAL?]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/optimize_final_vs_final</id>
        <link href="https://clickhouse.com/docs/knowledgebase/optimize_final_vs_final"/>
        <updated>2025-07-20T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Discusses the differences between OPTIMIZE FINAL and FINAL, and when to use and avoid them.]]></summary>
        <content type="html"><![CDATA[Discusses the differences between OPTIMIZE FINAL and FINAL, and when to use and avoid them.<!-- -->
<!-- -->
<p><code>OPTIMIZE FINAL</code> is a DDL command that physically and permanently reorganizes
and optimizes data on disk. It physically merges data parts in <code>MergeTree</code> tables,
performing data deduplication in the process by removing duplicate rows from storage.</p>
<p><code>FINAL</code> is a <strong>query-time</strong> modifier that provides deduplicated results without
changing the structure of the stored data. It works by performing merge logic at
read-time. It is temporary, only affecting the current query result.</p>
<p>Users are often advised to avoid using <code>OPTIMIZE FINAL</code>, as it has a significant
performance overhead, however they should not confuse the two. It is often necessary
to use <code>FINAL</code> to get back results without duplicates, especially when using table
engines like <code>ReplacingMergeTree</code> which may contain duplicate rows which have not
been replaced during the eventual, background merge process.</p>
<p>The table below summarises the key differences:</p>
<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	High 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>
<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>
<p>Use <code>OPTIMIZE FINAL</code> when:</p>
<ul class="custom-ul">
<li class="custom-li">You want to permanently improve query performance</li>
<li class="custom-li">You can afford the one-time optimization cost</li>
<li class="custom-li">You're doing periodic table maintenance</li>
<li class="custom-li">You want to physically clean up duplicate data</li>
</ul>
<p>Use <code>FINAL</code> when:</p>
<ul class="custom-ul">
<li class="custom-li">You need deduplicated results immediately</li>
<li class="custom-li">You can't wait for or don't want permanent optimization</li>
<li class="custom-li">You only occasionally need deduplicated data</li>
<li class="custom-li">You're working with frequently changing data</li>
</ul>
<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>]]></content>
        <category label="Core Data Concepts" term="Core Data Concepts"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Create a custom DNS alias by setting up a reverse proxy]]></title>
        <id>https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance</id>
        <link href="https://clickhouse.com/docs/knowledgebase/custom-dns-alias-for-instance"/>
        <updated>2025-05-16T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Learn how to set up a custom DNS alias for your instance using a reverse proxy]]></summary>
        <content type="html"><![CDATA[Learn how to set up a custom DNS alias for your instance using a reverse proxy<!-- -->
<!-- -->
<br>
<br>
<blockquote>
<p>In this knowledgebase article, we will walk you through how you can set up a
custom DNS alias for your ClickHouse Cloud instance through the use of a reverse
proxy such as Nginx for ClickHouse native client.</p>
</blockquote>
<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>
<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>
<p>Create a self-signed certificate with the domain name of your choice.
In this example we will use a domain name <code>xyz-customdomain.com</code> and
create 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>
for further details.</p>
<p>Add the certificate to <code>/etc/clickhouse-client/config.xml</code>:</p>
<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;
    &lt;openSSL&gt;
        &lt;client&gt;
            &lt;loadDefaultCAFile&gt;false&lt;/loadDefaultCAFile&gt;
            # highlight-next-line
            &lt;caConfig&gt;/etc/ssl/certs/MyCertificate.crt&lt;/caConfig&gt;
            &lt;cacheSessions&gt;true&lt;/cacheSessions&gt;
            &lt;disableProtocols&gt;sslv2,sslv3&lt;/disableProtocols&gt;
            &lt;preferServerCiphers&gt;true&lt;/preferServerCiphers&gt;
            &lt;invalidCertificateHandler&gt;
                &lt;name&gt;RejectCertificateHandler&lt;/name&gt;
            &lt;/invalidCertificateHandler&gt;
        &lt;/client&gt;
    &lt;/openSSL&gt;
&lt;/clickhouse&gt;
</code></pre></div><div class="activity_PoTP"></div></div>
<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>
<p>Add the following in your <code>nginx.conf</code> file:</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">proxy_ssl_name xyz.us-west-2.aws.clickhouse.cloud;
proxy_ssl_server_name on;
</code></pre></div><div class="activity_PoTP"></div></div>
<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 {
    upstream stream_backend {
         server xyz.us-west-2.aws.clickhouse.cloud:9440;
    }

    server {
        listen                9440 ssl;
        proxy_pass            stream_backend;

        ssl_certificate       /etc/ssl/certs/MyCertificate.crt;
        ssl_certificate_key   /etc/ssl/certs/MyKey.key;
        ssl_protocols         SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers           HIGH:!aNULL:!MD5;
        ssl_session_cache     shared:SSL:20m;
        ssl_session_timeout   4h;
        ssl_handshake_timeout 30s;
	proxy_ssl on;
	proxy_ssl_trusted_certificate /etc/ssl/certs/isrgrootx1.pem;
	proxy_ssl_session_reuse on;
        proxy_ssl_verify on;
    #highlight-next-line
	proxy_ssl_name xyz.us-west-2.aws.clickhouse.cloud;
    #highlight-next-line
	proxy_ssl_server_name on;
    }
}
</code></pre></div><div class="activity_PoTP"></div></div>
<p>Where <code>isrgrootx1.pem</code> is the root certificate for ClickHouse Cloud which you
can download <a href="https://letsencrypt.org/certs/isrgrootx1.pem" target="_blank" rel="noopener noreferrer">here</a>.</p>
<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>
<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>
<p>Add the following to your <code>/etc/hosts</code> file on the Nginx server:</p>
<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
::1         localhost6 localhost6.localdomain6
10.X.Y.Z  xyz-customdomain.com
</code></pre></div><div class="activity_PoTP"></div></div>
<p>Where <code>10.X.Y.Z</code> is the IP address of your specific Nginx box.</p>
<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>
<p>You are now ready to connect using your custom alias:</p>
<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'
ClickHouse client version 23.12.1.428 (official build).
Connecting to xyz.customdomain.com:9440 as user default.
Connected to ClickHouse server version 23.9.2.

clickhouse-cloud :)
</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>]]></content>
        <category label="Server Admin" term="Server Admin"/>
        <category label="Security and Authentication" term="Security and Authentication"/>
    </entry>
</feed>