SQL Dialects [2026]: DuckDB vs ClickHouse vs CockroachDB
Bottom Line
Treat these as three different SQL operating models, not interchangeable databases with different logos. DuckDB is the fastest path to local analytical work, ClickHouse is the OLAP specialist, and CockroachDB is the distributed SQL choice when multi-region correctness matters.
Key Takeaways
- ›DuckDB 1.5.2 is PostgreSQL-leaning, but still adds non-portable shortcuts like
==and//. - ›ClickHouse wins scan-heavy OLAP with columnar extensions such as
FINAL,FORMAT, and querySETTINGS. - ›CockroachDB v26.1 is the multi-region transactional option with
LOCALITY,SHOW RANGES, andAS OF SYSTEM TIME. - ›Portability usually breaks on config scope first:
PRAGMA/SET, querySETTINGS, and cluster settings differ.
As of May 13, 2026, these three engines sit in different corners of the SQL map: DuckDB 1.5.2 is local-first and PostgreSQL-leaning, ClickHouse is a fast analytical dialect with aggressive extensions, and CockroachDB v26.1 is the distributed SQL option for multi-region correctness. This cheat sheet is for engineers who need quick syntax recall, deployment fit, and tuning scope without reading three doc sets end to end.
- DuckDB is the easiest place to start if your workload begins with files, notebooks, or embedded analytics.
- ClickHouse is the strongest default for high-volume analytical scans, rollups, and real-time dashboards.
- CockroachDB is the best fit when data placement, regional latency, and transactional safety are product requirements.
- Assume low portability for engine-specific knobs: PRAGMA, query SETTINGS, and cluster settings solve different problems.
| Dimension | DuckDB | ClickHouse | CockroachDB | Edge |
|---|---|---|---|---|
| SQL baseline | PostgreSQL-style dialect with explicit differences | Analytical SQL with many engine-specific extensions | Majority PostgreSQL syntax plus pgwire compatibility | CockroachDB |
| Best default shape | Embedded, single-process analytics | Columnar OLAP and real-time analytics | Distributed transactional SQL | Depends on workload |
| Parquet and file-first work | Excellent | Possible, but not the main ergonomic path | Not the point | DuckDB |
| Petabyte-scale scan economics | Limited by local/runtime envelope | Designed for it | Not the primary design center | ClickHouse |
| Multi-region locality controls | None at database topology level | Replication and sharding architecture, but not transactional locality semantics | LOCALITY GLOBAL, REGIONAL BY TABLE, REGIONAL BY ROW | CockroachDB |
| Historical reads | No comparable built-in time-travel primitive | Engine-specific patterns, not the core SQL surface here | AS OF SYSTEM TIME | CockroachDB |
| Operational surface area | Smallest | Moderate to large | Largest | DuckDB |
Dialect Snapshot
Bottom Line
DuckDB is the fast local analyst, ClickHouse is the OLAP specialist, and CockroachDB is the distributed SQL system. Choose by query shape and data-placement needs before you compare syntax niceties.
What actually changes between them
- DuckDB tracks PostgreSQL conventions closely, but deliberately diverges on items like floating-point division, integer division, identifier handling, and permissive equality checks.
- ClickHouse extends SQL for analytics with patterns such as query SETTINGS, output FORMAT, and storage-aware modifiers like FINAL.
- CockroachDB supports the PostgreSQL wire protocol and the majority of PostgreSQL syntax, but distributed-system constraints still make some PostgreSQL features unsupported or behaviorally different.
Version and release context
- DuckDB 1.5.2 is the current release line on the official install page, with 1.4.4 listed as LTS.
- ClickHouse describes itself as shipping monthly releases and introduced the official clickhousectl CLI in beta on April 9, 2026.
- CockroachDB stable docs currently expose the v26.1 release line, while compatibility pages already document some behavior in v26.2.
When To Choose Each
Choose DuckDB when:
- You start from Parquet, CSV, notebooks, or an embedded app process.
- You want near-zero operational work and fast local iteration.
- You need PostgreSQL-flavored SQL, but not a distributed cluster.
- You care more about developer speed than cross-region writes.
Choose ClickHouse when:
- You need fast scans, rollups, and dashboards over very large analytical data.
- You are comfortable using engine-specific SQL extensions for performance.
- You want columnar storage, strong compression, and ClickBench-style performance expectations.
- You can separate operational analytics from transactional system-of-record concerns.
Choose CockroachDB when:
- You need transactional SQL across regions, not just replicated analytics.
- Read/write locality is part of the schema design, not an afterthought.
- You want PostgreSQL driver and tool compatibility, but with distributed placement controls.
- You need first-class range visibility and historical reads for debugging or correctness.
Live Filter And Shortcuts
Use the search box or the keyboard shortcuts below to jump around quickly.
| Shortcut | Action | Why it helps |
|---|---|---|
/ | Focus the live filter | Fastest way to narrow commands by feature or engine. |
j | Jump to next <h2> | Moves down the cheat sheet without scrolling hunts. |
k | Jump to previous <h2> | Useful when you overshoot a section. |
c | Copy the first visible code block | Pairs well with the built-in copy buttons on all snippets. |
Esc | Clear the filter | Resets the grid to the full reference set. |
Commands By Purpose
1. Connect, attach, or start
DuckDB
duckdb
ATTACH 'file.db';
USE file;
ATTACH 'sqlite_file.db' AS sqlite_db (TYPE sqlite);ClickHouse
clickhouse-client --host <hostname> \
--secure \
--port 9440 \
--user <username> \
--password <password>CockroachDB
cockroach demo movr --nodes 3;
SHOW REGIONS FROM DATABASE movr;2. Inspect schema, plans, and metadata
DuckDB
PRAGMA version;
SHOW TABLES;
DESCRIBE SELECT * FROM 'events.parquet';ClickHouse
EXPLAIN SYNTAX
SELECT sum(number)
FROM (SELECT * FROM numbers(10000))
WHERE number <= 10;CockroachDB
EXPLAIN SELECT * FROM rides WHERE city = 'new york';
SHOW RANGES FROM TABLE movr.users WITH DETAILS;3. Query and tune for performance
DuckDB
SET memory_limit = '10GB';
SET threads TO 4;
EXPLAIN ANALYZE
SELECT city, count(*)
FROM read_parquet('events/*.parquet')
GROUP BY city;ClickHouse
SELECT count()
FROM events
SETTINGS max_threads = 4;
SELECT *
FROM events FINAL
FORMAT Null;
EXPLAIN PIPELINE
SELECT count()
FROM events
SETTINGS max_threads = 4;CockroachDB
EXPLAIN ANALYZE (REDACT)
SELECT *
FROM rides
WHERE revenue > 90
ORDER BY revenue ASC;4. Distributed or engine-specific power moves
DuckDB
SELECT *
FROM read_parquet(['file1.parquet', 'file2.parquet']);
LOAD httpfs;
ATTACH 'encrypted.db' AS enc_db (ENCRYPTION_KEY 'quack_quack');ClickHouse
SELECT *
FROM actors AS a
JOIN roles AS r ON a.id = r.actor_id
FORMAT Null
SETTINGS join_algorithm = 'parallel_hash';CockroachDB
CREATE TABLE promo_codes (
code STRING PRIMARY KEY,
description STRING
) LOCALITY GLOBAL;
CREATE TABLE vehicles (
id UUID PRIMARY KEY,
city STRING,
owner_id UUID
) LOCALITY REGIONAL BY ROW;
SELECT *
FROM rides AS OF SYSTEM TIME '-4h';Configuration And Session Controls
Scope matters more than syntax
- DuckDB uses SET and PRAGMA for session-level behavior. You can inspect current values with
current_setting()orduckdb_settings(). - ClickHouse commonly exposes tuning at query time through the SETTINGS clause, which keeps performance intent close to the statement.
- CockroachDB separates session variables from cluster-wide controls. Use SHOW CLUSTER SETTINGS and SET CLUSTER SETTING only when you really mean global impact.
| Engine | Config style | Typical scope | Watch out for |
|---|---|---|---|
| DuckDB | PRAGMA, SET, RESET | Connection or session | Small syntax changes can alter semantics, not just speed. |
| ClickHouse | Query SETTINGS | Per statement or workload slice | Very powerful, but the SQL becomes engine-specific fast. |
| CockroachDB | Session vars plus cluster settings | Session or full cluster | Global changes propagate across nodes and can affect every app. |
-- DuckDB
SELECT current_setting('memory_limit') AS memlimit;
-- CockroachDB
SHOW CLUSTER SETTINGS;
SHOW CLUSTER SETTING diagnostics.reporting.enabled;
SET CLUSTER SETTING <setting> = <value>;If you need to sanitize examples before sharing traces, plan bundles, or SQL samples externally, use TechBytes' Data Masking Tool. It fits especially well beside CockroachDB plan output and any ad hoc snippets you lift from production tickets.
Advanced Usage And Gotchas
DuckDB portability traps
- DuckDB supports == for equality, while PostgreSQL does not.
- DuckDB uses // for integer division and returns floating-point results for
1 / 2, unlike PostgreSQL integer division. - Identifier handling is more forgiving than PostgreSQL because DuckDB preserves case while matching identifiers case-insensitively.
ClickHouse tuning traps
- FINAL is convenient, but it can be expensive because it forces extra work at query time.
- Analytical extensions such as FORMAT, SETTINGS, and join algorithm hints are useful precisely because they are not generic SQL.
- Expect the best results when you write for the engine, not when you try to preserve strict PostgreSQL portability.
CockroachDB distributed SQL traps
- EXPLAIN ANALYZE executes the target statement. It is not a dry run.
- REGIONAL BY ROW is powerful, but only when your access patterns actually align to row locality.
- AS OF SYSTEM TIME is a practical debugging and conflict-reduction primitive, but it is still bounded by the garbage-collection window.
Decision shortcut
- Need local analytics over files today: choose DuckDB.
- Need the fastest analytical warehouse path tomorrow: choose ClickHouse.
- Need globally distributed writes with SQL locality semantics: choose CockroachDB.
Frequently Asked Questions
Which SQL dialect is best for querying Parquet files locally in 2026? +
read_parquet() or direct file reads keep the workflow short. If the work starts on a laptop or inside CI, DuckDB usually wins on friction alone.Is ClickHouse SQL close enough to PostgreSQL to reuse app queries? +
SETTINGS, FORMAT, and modifiers like FINAL. Treat it as an analytical dialect you intentionally target, not a drop-in PostgreSQL replacement.What makes CockroachDB the safest choice for multi-region SQL? +
LOCALITY GLOBAL, REGIONAL BY TABLE, and REGIONAL BY ROW. It also gives you operational visibility through SHOW RANGES and historical reads through AS OF SYSTEM TIME. That combination is the main reason it stands apart from the other two in distributed transactional workloads.How portable are queries between DuckDB and CockroachDB? +
Get Engineering Deep-Dives in Your Inbox
Weekly breakdowns of architecture, security, and developer tooling — no fluff.