ClickHouse icon

ClickHouse

Query, insert, update, delete, and manage ClickHouse tables. Supports AI agent tool use with schema discovery, auto-pagination for large results, and parameterized queries.

Execute Query

AI-generated

Summary

Execute a SELECT query against ClickHouse, optionally with parameters, pagination, and statistics.

Inputs

  • query (required) — The SELECT SQL query to execute. Use {name:Type} placeholders for parameterized queries.
  • queryParameters — Parameters for the query. Define values for {name:Type} placeholders.
  • limit — Maximum number of rows to return per page.
  • offset — Number of rows to skip (for pagination).
  • autoPaginate — Fetch all result pages automatically using LIMIT/OFFSET.
  • maxRows — Maximum total rows to fetch across all pages.
  • pageSize — Number of rows to fetch per HTTP request when auto-paginating.
  • includeStats — Include execution statistics (rows_read, bytes_read, elapsed) from X-ClickHouse-Summary header.
  • queryId — Optional query identifier for tracking and cancellation; returned in the output.
  • querySettings — JSON string of ClickHouse settings to pass as URL parameters (e.g. max_execution_time).

Output shape

list of items

Each item contains the query result row(s); when autoPaginate is enabled multiple rows may be aggregated, and the output may include optional fields _stats and _queryId.

Examples

Example 1: Simple parameterized SELECT

Query: SELECT * FROM users WHERE id = {id:UInt64}; Query Parameters: [{name: "id", value: "42"}]; Limit: 10

Example 2: Fetch all pages of a large result set

Enable Auto-Paginate; set Max Total Rows to 100000; Page Size 5000; optionally includeStats true

Example 3: Execute a query with custom settings

Query: SELECT name, email FROM users FORMAT JSONEachRow; Query Settings: {"max_execution_time": 30}; Include Query Stats: true

Links

Discussion