ClickHouse/clickhouse-docs-embeddings huggingface dataset:
title_wip

Learn how to use the `clickhouse-local` tool to export MySQL data into formats like Parquet, CSV, or JSON quickly and efficiently.


## Exporting MySQL Data to Parquet, CSV, or JSON Using ClickHouse[​](#exporting-mysql-data-to-parquet-csv-or-json-using-clickhouse "Direct link to Exporting MySQL Data to Parquet, CSV, or JSON Using ClickHouse")

The `clickhouse-local` tool makes it quick and easy to read data from MySQL and output the data into lots of different formats, including Parquet, CSV, and JSON. We are going to:

- Use the [`mysql` table function](https://clickhouse.com/docs/sql-reference/table-functions/mysql) to read the data
- Use the `INTO OUTFILE _filename_ FORMAT` clause and specify the desired output format

The `clickhouse-local` tool is a part of the ClickHouse binary. Download it using the following:

```
curl https://clickhouse.com/ | sh
```

## Export MySQL to Parquet[​](#export-mysql-to-parquet "Direct link to Export MySQL to Parquet")

The `mysql` table function creates a table based on the results of a query sent to a MySQL instance. For example:

```
SELECT *
FROM
   mysql(
    'localhost:3306',
    'my_sql_database',
    'my_sql_table',
    'user',
    'password'
);
```

We can pipe the output of this query to a file using `INTO OUTFILE`. Use `FORMAT` to specify the format of the file to be created. Let's grab the entire contents of a MySQL table, and send its contents to a Parquet file:

```
./clickhouse local -q "SELECT * FROM
   mysql(
    'localhost:3306',
    'my_sql_database',
    'my_sql_table',
    'user',
    'password'
)
INTO OUTFILE 'my_output_file.parquet'"
```

Note

Because the name of the output file has a `.parquet` extension, ClickHouse assumes we want the Parquet format, so notice we omitted the `FORMAT Parquet` clause.

## Export MySQL to CSV[​](#export-mysql-to-csv "Direct link to Export MySQL to CSV")

It's the same as for Parquet, except this time we use a `.csv` extension on the filename. ClickHouse will realize we want a comma-separated output and that's how the data will be written to the file:

```
./clickhouse local -q "SELECT * FROM
   mysql(
    'localhost:3306',
    'my_sql_database',
    'my_sql_table',
    'user',
    'password'
)
INTO OUTFILE 'my_output_file.csv'"
```

## Export MySQL to JSON[​](#export-mysql-to-json "Direct link to Export MySQL to JSON")

To go from MySQL to JSON, just change the extension on the filename to `jsonl` or `ndjson`:

```
./clickhouse local -q "SELECT * FROM
   mysql(
    'localhost:3306',
    'my_sql_database',
    'my_sql_table',
    'user',
    'password'
)
INTO OUTFILE 'my_output_file.ndjson'"
```

It's impressive how simple yet powerful the `clickhouse-local` tool really is. You can easily read data from a database like MySQL and output it into [all types of different output formats](https://clickhouse.com/docs/sql-reference/formats/).

Mar 21, 2023 · 2 min read
title_wip

Learn how to use @clickhouse/client in a Node.js application to interact with ClickHouse and perform queries.


## Use NodeJS with @clickhouse/client[​](#use-nodejs-with-clickhouseclient "Direct link to Use NodeJS with @clickhouse/client")

Here is a basic code snippet file `main.ts`.

`Package.json` (place it under `./`):

```
{
  "name": "a simple clickhouse client example",
  "version": "1.0.0",
  "main": "main.js",
  "license": "MIT",
  "devDependencies": {
    "typescript": "^5.3.2"
  },
  "dependencies": {
    "@clickhouse/client": "^0.2.6"
  }
}
```

`Main.ts` (place it under `./src`):

```
import { ClickHouseClient, createClient } from '@clickhouse/client'; // or '@clickhouse/client-web'

interface ClickHouseResultSet<T> {
  meta: Meta[];
  data: T[];
  rows: number;
  statistics: Statistics;
}

interface Statistics {
  elapsed: number;
  rows_read: number;
  bytes_read: number;
}

interface Meta {
  name: string;
  type: string;
}

interface Count {
  c: number;
}

//Please replace client connection parameters like`host`
//`username`, `passowrd`, `database` as needed.

const initClickHouseClient = async (): Promise<ClickHouseClient> => {
  const client = createClient({
    host: 'https://FQDN.aws.clickhouse.cloud',
    username: 'default',
    password: 'password',
    database: 'default',
    application: `pingpong`,
  });

  console.log('ClickHouse ping');
  if (!(await client.ping())) {
    throw new Error('failed to ping clickhouse!');
  }
  console.log('ClickHouse pong!');
  return client;
};

const main = async () => {
  console.log('Initialising clickhouse client');
  const client = await initClickHouseClient();

  const row = await client.query({
    query: `SELECT count() AS c FROM system.tables WHERE database='system'`,
  });

  const jsonRow: ClickHouseResultSet<Count> = await row.json();

  console.log(`I have found ${jsonRow.data[0].c} system tables!`);

  await client.close();
  console.log(`👋`);
};

main();
```

To install the packages, run `yarn` from `./`:

```
$ yarn
yarn install v1.22.19
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
✨  Done in 0.14s.
```

execute the code in `main.ts` from `./` with:

```
$ npx ts-node src/main.ts
```

will output:

```
Initialising clickhouse client
ClickHouse ping
ClickHouse pong!
I have found 120 system tables!
👋
```

Nov 22, 2023 · 2 min read
This article shows you how you can opt out of crash report collection on ClickHouse Cloud


## Overview[​](#overview "Direct link to Overview")

Starting **February 27, 2026**, ClickHouse Cloud will begin collecting crash reports when server crashes occur. This is part of our commitment to improving service reliability for all our users.

Crash report collection helps us:

- Identify and understand what caused a crash
- Fix issues more quickly
- Continuously improve your service experience

## What's collected[​](#whats-collected "Direct link to What's collected")

When a crash occurs, crash reports capture a snapshot of the server's state at that moment. We want to be transparent that this may include sensitive information that was in memory, such as:

- Connection credentials
- Encryption keys
- Query strings
- Other data in memory at the time of the crash

### How we protect your data[​](#how-we-protect-your-data "Direct link to How we protect your data")

We take the security of this data seriously:

- **Regional Storage**: All data stays in the same region as your service
- **Enhanced Security**: We apply additional protections to all collected data
- **Limited Retention**: Data is kept only as long as needed for debugging, then securely deleted

## Services automatically excluded[​](#services-automatically-excluded "Direct link to Services automatically excluded")

Some services are automatically excluded from crash report collection:

- Services with **HIPAA** compliance requirements
- Services with **PCI** compliance requirements
- **BYOC** (Bring Your Own Cloud) services

## How to opt out[​](#how-to-opt-out "Direct link to How to opt out")

If you'd prefer not to participate in crash report collection, you can easily opt out:

1. Go to the [ClickHouse Cloud Console](https://clickhouse.cloud)
2. Select your service
3. Click on the **Settings** tab
4. Scroll to find "Share crash reports with ClickHouse"
5. Toggle the option off to opt out

Note

In addition to the service setting, we also support configuring preferences for the organization. If the setting is disabled, i.e., opt out of the crash report collection, all existing and new services will be opted out automatically. If you set the preference to enabled i.e. opt in, you can selectively disable at the service level to override and opt out.

Feb 4, 2026 · 2 min read
title_wip

Discusses the differences between OPTIMIZE FINAL and FINAL, and when to use and avoid them.


`OPTIMIZE FINAL` is a DDL command that physically and permanently reorganizes
and optimizes data on disk. It physically merges data parts in `MergeTree` tables,
performing data deduplication in the process by removing duplicate rows from storage.

`FINAL` is a **query-time** 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.

Users are often advised to avoid using `OPTIMIZE FINAL`, as it has a significant
performance overhead, however they should not confuse the two. It is often necessary
to use `FINAL` to get back results without duplicates, especially when using table
engines like `ReplacingMergeTree` which may contain duplicate rows which have not
been replaced during the eventual, background merge process.

The table below summarises the key differences:

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Aspect `OPTIMIZE FINAL` `FINAL`|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | Type DDL Command Query Modifier|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | Effect Permanent storage optimization Temporary query-time deduplication|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | Performance Impact High cost once, then faster queries Lower individual cost, but repeated for each query|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | Data Modification Yes - physically changes storage No - read-only operation|  |  |  | | --- | --- | --- | | Use Case Periodic maintenance/optimization Real-time deduplicated queries | | | | | | | | | | | | | | | | | |

## When to use each[​](#when-to-use-each "Direct link to When to use each")

Use `OPTIMIZE FINAL` when:

- You want to permanently improve query performance
- You can afford the one-time optimization cost
- You're doing periodic table maintenance
- You want to physically clean up duplicate data

Use `FINAL` when:

- You need deduplicated results immediately
- You can't wait for or don't want permanent optimization
- You only occasionally need deduplicated data
- You're working with frequently changing data

Both are valuable tools, but they serve different purposes in ClickHouse's deduplication strategy.

Jul 20, 2025 · 2 min read
title_wip

If you use Oracle as a source of ClickHouse external dictionaries via Oracle ODBC driver, you need to set the correct value for the `NLS\_LANG` environment variable in `/etc/default/clickhouse`.


## What to do[​](#what-to-do "Direct link to What to do")

If you use Oracle as a source of ClickHouse external dictionaries via Oracle ODBC driver, you need to set the correct value for the `NLS_LANG` environment variable in `/etc/default/clickhouse`.

For more information, see the [Oracle NLS\_LANG FAQ](https://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html).

**Example**

```
NLS_LANG=RUSSIAN_RUSSIA.UTF8
```

Apr 22, 2022 · One min read
# Knowledge Base

RecentGrouped by tags

This KB article explores whether Materialized Views are inserted synchronously

Mar 1, 2023 · 2 min read

The new setting `allow\_asynchronous\_read\_from\_io\_pool\_for\_merge\_tree` allows the number of reading threads (streams) to be higher than the number of threads in the rest of the query execution pipeline.

Mar 1, 2023 · 4 min read

Learn how to define settings in ClickHouse for individual queries, client sessions, or specific users using `SET` and `ALTER USER` commands.

Mar 1, 2023 · 2 min read

Learn how to use `ON CLUSTER` and `clusterAllReplicas` to execute SYSTEM statements and queries across all nodes in a ClickHouse Cloud service.

Mar 1, 2023 · One min read

Learn how to use filtered aggregates in ClickHouse with `-If` and `-Distinct` aggregate combinators to simplify query syntax and enhance analytics.

Mar 1, 2023 · One min read

Learn how to configure the Global Thread pool in ClickHouse by adjusting settings like `max\_thread\_pool\_size`, `thread\_pool\_queue\_size`, and `max\_thread\_pool\_free\_size`.

Mar 1, 2023 · One min read

Learn how to use the `skip\_check\_for\_incorrect\_settings` option to allow ClickHouse to start even when user-level settings are specified incorrectly.

Mar 1, 2023 · One min read

Learn how to capture server logs at the client level, even with different log settings, using the `send\_logs\_level` client setting.

Mar 1, 2023 · One min read

A query to compare metrics between two queries in ClickHouse.

Jan 14, 2023 · 7 min read

Learn how to resolve ingest failures caused by stricter grant checking introduced in ClickHouse 23.9 for tables using `async\_inserts`. Update grants to fix errors.

Nov 17, 2022 · One min read
# Knowledge Base

RecentGrouped by tags

Learn how to optimize Map column lookups in ClickHouse for better query performance by materializing specific keys as standalone columns.

Oct 30, 2022 · 3 min read

The short answer is "yes". ClickHouse has multiple mechanisms that allow freeing up disk space by removing old data. Each mechanism is aimed for different scenarios.

Oct 19, 2022 · 2 min read

Learn how to check if a projection is used in ClickHouse queries by testing with sample data and using EXPLAIN to verify projection usage.

Jul 10, 2022 · 2 min read

An example using Python and requests module to write and read to ClickHouse

Jul 10, 2022 · 2 min read

How to enforce limit on max query execution time

Jul 10, 2022 · One min read

The short answer is yes. However, we recommend keeping latency between all regions/datacenters in two-digit range, otherwise write performance will suffer as it goes through distributed consensus protocol.

Apr 22, 2022 · One min read

If you use Oracle as a source of ClickHouse external dictionaries via Oracle ODBC driver, you need to set the correct value for the `NLS\_LANG` environment variable in `/etc/default/clickhouse`.

Apr 22, 2022 · One min read

A columnar database stores the data of each column independently. This allows reading data from disk only for those columns that are used in any given query.

Sep 1, 2021 · 2 min read

Curious what ClickHouse means? Take a look inside this knowledge base article to find out!

Sep 1, 2021 · One min read

ClickHouse is an open-source project developed on GitHub. As customary, contribution instructions are published in CONTRIBUTING file in the root of the source code repository.

Sep 1, 2021 · One min read
# Knowledge Base

RecentGrouped by tags

A short example on how to extract base types from JSON

Sep 1, 2021 · One min read

The short answer is \*\*"no"\*\*. The key-value workload is among top positions in the list of cases when \*\*NOT\*\* to use ClickHouse.

Sep 1, 2021 · 2 min read

We can refer to systems like MapReduce as distributed computing systems in which the reduce operation is based on distributed sorting. The most common open-source solution in this class is Apache Hadoop.

Sep 1, 2021 · 2 min read

Learn the recommended maximum limits for databases, tables, partitions, and parts in a ClickHouse cluster to ensure optimal performance.

Sep 1, 2021 · One min read

OLAP stands for Online Analytical Processing. It is a broad term that can be looked at from two perspectives: technical and business.

Sep 1, 2021 · 3 min read

First of all, let’s discuss why people ask this question in the first place. There are two key reasons...

Sep 1, 2021 · 6 min read

ClickHouse is a generic data storage solution for OLAP workloads, while there are many specialized time-series database management systems.

Sep 1, 2021 · 2 min read

Being an open-source product makes this question not so straightforward to answer. You do not have to tell anyone if you want to start using ClickHouse, you just go grab source code or pre-compiled packages.

Sep 1, 2021 · 2 min read