Home Posts SQL Dialects [2026]: DuckDB vs ClickHouse vs CockroachDB
Developer Reference

SQL Dialects [2026]: DuckDB vs ClickHouse vs CockroachDB

SQL Dialects [2026]: DuckDB vs ClickHouse vs CockroachDB
Dillip Chowdary
Dillip Chowdary
Tech Entrepreneur & Innovator · May 13, 2026 · 11 min read

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 query SETTINGS.
  • CockroachDB v26.1 is the multi-region transactional option with LOCALITY, SHOW RANGES, and AS OF SYSTEM TIME.
  • Portability usually breaks on config scope first: PRAGMA/SET, query SETTINGS, 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.
DimensionDuckDBClickHouseCockroachDBEdge
SQL baselinePostgreSQL-style dialect with explicit differencesAnalytical SQL with many engine-specific extensionsMajority PostgreSQL syntax plus pgwire compatibilityCockroachDB
Best default shapeEmbedded, single-process analyticsColumnar OLAP and real-time analyticsDistributed transactional SQLDepends on workload
Parquet and file-first workExcellentPossible, but not the main ergonomic pathNot the pointDuckDB
Petabyte-scale scan economicsLimited by local/runtime envelopeDesigned for itNot the primary design centerClickHouse
Multi-region locality controlsNone at database topology levelReplication and sharding architecture, but not transactional locality semanticsLOCALITY GLOBAL, REGIONAL BY TABLE, REGIONAL BY ROWCockroachDB
Historical readsNo comparable built-in time-travel primitiveEngine-specific patterns, not the core SQL surface hereAS OF SYSTEM TIMECockroachDB
Operational surface areaSmallestModerate to largeLargestDuckDB

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.
Pro tip: If your architecture already has an OLTP database, the cleanest split is often CockroachDB or PostgreSQL for writes and ClickHouse for analytics. Reach for DuckDB when the job is local exploration, CI checks, or embedded analytics inside a tool.

Live Filter And Shortcuts

Use the search box or the keyboard shortcuts below to jump around quickly.

ShortcutActionWhy it helps
/Focus the live filterFastest way to narrow commands by feature or engine.
jJump to next <h2>Moves down the cheat sheet without scrolling hunts.
kJump to previous <h2>Useful when you overshoot a section.
cCopy the first visible code blockPairs well with the built-in copy buttons on all snippets.
EscClear the filterResets 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() or duckdb_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.
EngineConfig styleTypical scopeWatch out for
DuckDBPRAGMA, SET, RESETConnection or sessionSmall syntax changes can alter semantics, not just speed.
ClickHouseQuery SETTINGSPer statement or workload sliceVery powerful, but the SQL becomes engine-specific fast.
CockroachDBSession vars plus cluster settingsSession or full clusterGlobal 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.
Watch out: The biggest migration mistake is comparing these engines only on ANSI SQL checklists. The real breakpoints are storage layout, topology, and the operational scope of each tuning command.

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? +
DuckDB is the clear default. Its SQL surface treats local and data-lake files as first-class inputs, and commands like 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? +
Usually not for anything non-trivial. Basic SQL feels familiar, but the value in ClickHouse comes from engine-specific constructs such as 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? +
CockroachDB exposes locality in the schema itself with 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? +
More portable than either is with ClickHouse, but still not perfectly portable. DuckDB diverges from PostgreSQL semantics in places like integer division, floating-point behavior, and permissive equality, while CockroachDB intentionally omits or changes some PostgreSQL features for distributed-system reasons. Shared syntax helps, but test the edge cases that matter to your application.

Get Engineering Deep-Dives in Your Inbox

Weekly breakdowns of architecture, security, and developer tooling — no fluff.

Found this useful? Share it.