
**Subject: Postgres → ClickHouse: Sling is ~1 core per ~11K rows/s, ~6× slower than a small DuckDB script. Plus a bug with direct insert + chunking**

I've been benchmarking a Postgres → ClickHouse load and would like your view on the numbers, plus one bug.

**Setup:** Sling 1.6.5 (Pro), 4-CPU Linux VM. Source: Postgres (`use_adbc: true`). Target: ClickHouse Cloud (`use_adbc: true`). Table: 8.25M rows, 72 columns (ints, strings, `Decimal(25,8)`, `DateTime64(6)`). The debug log shows the target options as `batch_limit: 100000`, `use_bulk: true`.

```yaml
source: PG_ADBC
target: CH_CONN
env:
  SLING_THREADS: 4
defaults:
  mode: incremental
streams:
  myschema.big_table:
    object: '{target_schema}.big_table'
    update_key: etl_time
    sql: |
      SELECT * FROM myschema.big_table WHERE {incremental_where_cond}
    source_options:
      chunk_expr: mod(abs(hashtext(trade_key)::bigint), {chunk_count})
      chunk_count: 4
```

**Results**

| Run | Time | Rows/s | Busy cores |
|---|---|---|---|
| Sling, 1 stream, direct insert | — | ~11K | ~1.15 |
| Sling, `chunk_count: 4`, regular ClickHouse driver | 6m38s | ~20.7K (~5.4K per chunk) | ~2.7 |
| Same, ClickHouse `use_adbc: true` | 6m44s | ~20.4K | ~2.8 |
| DuckDB `ATTACH` Postgres (parallel scan) → Arrow → `clickhouse-connect insert_arrow`, 250K-row inserts, 3 at a time | 63 s | 130K | — |
| DuckDB parallel read alone (no insert) | 25 s | 331K | — |

**What it looks like:** each Sling stream is limited by one CPU core at about 11K rows/s for this table. Chunking helps only until the box runs out of cores. ADBC on the ClickHouse side and direct insert vs temp table make little difference. DuckDB moves the same data roughly 6× faster on the same box.

**Questions**
1. Where does a stream spend its CPU on a Postgres → ClickHouse load? Is it per-value type conversion (`Decimal(25,8)`, `DateTime64(6)`), row-by-row processing, or something else? Is there a path that keeps the data in Arrow end to end?
2. Should a larger `batch_limit` (e.g. 250K) help with ClickHouse, or is the cost on the CPU side regardless of batch size?
3. ADBC is in use on both connections (we see `…-adbc-…` connections in the debug log), yet throughput didn't change. Does the ClickHouse ADBC writer receive Arrow batches directly, or are rows converted first? Is the Arrow Lane planned for ClickHouse targets?
4. Is there a setting to run more than one insert at a time within a single stream, without splitting the read into chunks? Each chunk re-scans the whole Postgres table.

**Bug: `SLING_DIRECT_INSERT` with chunking, when the target table doesn't exist yet**

With `SLING_DIRECT_INSERT: 'true'` and `chunk_count: 4`, all 4 chunks run `CREATE TABLE` on the final table at the same moment. The first one succeeds and the other three fail immediately:

```
Error creating table `ch_stg`.`big_table` as it already exists. A concurrent process created it, possibly another run of this stream (check for overlapping schedules)
clickhouse [execute]:: 500 code: Code: 57. DB::Exception: Table ... already exists. (TABLE_ALREADY_EXISTS)
```

The result is `1 Successes | 3 Failures` (exit code 11), with only a quarter of the rows loaded. Without direct insert it works, because each chunk creates its own `_00N` temp table. Expected: create the table once before the chunks start, or use `CREATE TABLE IF NOT EXISTS`.

I'm happy to run any test build or settings you'd like to try, and to send full debug logs (`-d`). Thanks!
