Skip to main content
vsql_stat_ch records one event for every statement the server finishes and ships them to ClickHouse in batches. Query history then lives somewhere you can aggregate it, without a collector process between the two. It speaks ClickHouse’s native protocol or HTTP, and you can switch between them while the server is running.
This extension uses four preview capabilities, so the server must be started with --vsql_allow_preview_extensions=ON. INSTALL EXTENSION is refused otherwise.

Install

vsql_stat_ch is not bundled with the server, so build it before installing it. Clone the repository with its submodules, because it vendors a ClickHouse client:
Copy the resulting vsql_stat_ch.veb into the directory named by the veb_dir system variable, then install it:
Confirm it is there:

What it adds

It adds a capture path, a set of settings, and a set of status counters, and no SQL functions.

Example

Point it at a ClickHouse instance and start capturing:
Watch what it is doing through the status counters:
events_dropped climbing means the queue filled faster than it drained, so either ClickHouse is slow to answer or queue_capacity is too small for the statement rate.
Statement text is truncated at statement_max_bytes, and statement text can carry literals from your data. Decide what your ClickHouse table is allowed to hold before you turn capture on.

See also