ClickHouse.Driver 1.0.0: The Official .NET Client Hits Stable
ClickHouse.Driver 1.0.0 is the first stable release of the official .NET client for ClickHouse, committing to a semver-stable public API. It introduces a thread-safe, singleton-friendly ClickHouseClient that replaces most ADO.NET usage and the deprecated ClickHouseBulkCopy, and adds parameter type extraction from SQL, JWT/roles/custom headers, POCO serialization to JSON columns, mid-stream exception detection and QBit vector support. Breaking changes matter for upgrades: .NET Framework/Standard support is dropped, timezone-less DateTime columns now return Kind=Unspecified, and JSON writes default to string mode parsed server-side, which can change inferred types (e.g. Int32 to Int64).
Related posts
- What's new in the ClickHouse .NET Driver: the road from 1.0 to 1.3
ClickHouse mediumAdept
ClickHouse's .NET driver versions 1.1 through 1.3 rework the insert, read and parameter paths. POCO registration replaces hand-built object[] rows for both inserts and typed QueryAsync<T> reads, with eager validation, precompiled accessors, attribute-based column mapping and JSON column support. Three optional extension points (IParameterTypeResolver, IParameterFormatter, IReadValueConverter) let callers control type inference, wire formatting and read-side conversion, and add no overhead when unused. The releases also add multidimensional arrays, ValueTuples and server-side Identifier parameters, plus a breaking fix that sends UTC/Local DateTime parameters as DateTime('UTC') so values are no longer shifted by the server's session time zone.
- Introducing the (blazing fast!) native TCP client for .NET
ClickHouse mediumAdept
ClickHouse's new experimental .NET client in the ClickHouse.Driver package speaks the native TCP protocol and the columnar Native format. This removes the row/column conversions that HTTP with RowBinary forces on both server and client. It is built on zero-copy, pooled buffers and MemoryMarshal reinterpretation, with compiled expression-tree mappers for POCOs and SIMD where wire and .NET layouts differ (e.g. UUID). The result is 1.5-2x faster reads and inserts than HTTP, up to 1.1M rows/s on a single stream, and allocations for a 1M-row read cut from 1.6 GB to 6 MB. The tradeoffs: no ADO.NET/ORM support, text-only JSON, borrowed blocks valid for one iteration, and little gain on the object[] tier.
- Structured Logging in .NET with Serilog and ClickHouse
ClickHouse mediumAdept
Serilog's ClickHouse sink lets an ASP.NET service write structured logs directly into a ClickHouse table with one WriteTo.ClickHouse() call. A fluent C# schema builder controls the table: typed JSON property hints, promoted columns such as CorrelationId, a text inverted index on messages, a MergeTree ORDER BY key and a TTL. The demo also covers correlation ID middleware via LogContext, single per-request summary events with UseSerilogRequestLogging and IDiagnosticContext, and flushing batched events with Log.CloseAndFlushAsync on shutdown. For production, manage the schema externally rather than letting the sink create it, and tune compression codecs and Kubernetes-aware sort keys.
- ClickHouse Newsletter April 2022: JSON, JSON, JSON
ClickHouse mediumAdept
ClickHouse 22.3 LTS adds an experimental JSON data type that stores semi-structured documents in a single column, with dynamic subcolumns underneath, so you no longer need hand-built schemas of arrays and materialized columns. The worked examples cover querying nested fields, loading files with the JSONAsString format, and pulling a timestamp into its own column so MergeTree has a usable sorting key. They also show how to display field names with output_format_json_named_tuples_as_objects. The release also ships ARM Docker images, fully tested S3 disk storage (with known performance issues), and a Hive table function, and ClickHouse Cloud's serverless waitlist is now open.
- What's New in pg_clickhouse - JSONB Support, SQL value functions, Streaming, and more
ClickHouse mediumAdept
pg_clickhouse, the Postgres foreign data wrapper for querying ClickHouse, now pushes down far more operations to ClickHouse. JSONB accessors (->, ->>, jsonb_extract_path) are translated to ClickHouse sub-column syntax. CURRENT_DATE, CURRENT_TIMESTAMP and clock_timestamp() are translated to ClickHouse now()/now64()/nowInBlock64 calls that use the Postgres session time zone and timestamp precision. Array functions now map to their ClickHouse equivalents. Streaming of HTTP driver results in roughly 50MB batches kept container memory under about 100MiB during a full NYC taxi table scan, versus about 600MiB without it.