Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpclickhouse Laravel Package

smi2/phpclickhouse

PHP client for ClickHouse with an easy, fluent API. Supports queries and inserts, result sets, bindings, and connection configuration for fast analytics workflows. Suitable for Laravel and standalone PHP apps needing reliable ClickHouse access.

View on GitHub
Deep Wiki
Context7

layout: default title: Insert Statistics & Summary

< Back to Home

Insert Statistics & Summary

The Problem

For SELECT queries, ClickHouse returns statistics (elapsed time, rows read, etc.) in the JSON response body. But for INSERT/write queries, the response body is empty — statistics are sent in the X-ClickHouse-Summary HTTP header instead.

summary()

The summary() method reads the X-ClickHouse-Summary response header:

$stat = $db->insert('my_table',
    [
        [1, 'a'],
        [2, 'b'],
        [3, 'c'],
    ],
    ['id', 'name']
);

// Get all summary data
print_r($stat->summary());
/*
[
    'read_rows' => '0',
    'read_bytes' => '0',
    'written_rows' => '3',
    'written_bytes' => '24',
    'total_rows_to_read' => '0',
]
*/

// Get specific key
echo $stat->summary('written_rows'); // '3'
echo $stat->summary('written_bytes'); // '24'

statistics() fallback

The statistics() method now falls back to summary() when the body doesn't contain statistics (i.e., for INSERT queries):

// Works for both SELECT and INSERT
$stat = $db->insert('my_table', $data, $columns);
$statistics = $stat->statistics(); // returns summary data for INSERT

$stat = $db->select('SELECT count() FROM my_table');
$statistics = $stat->statistics(); // returns body statistics for SELECT

Available summary keys

Key Description
read_rows Number of rows read
read_bytes Number of bytes read
written_rows Number of rows written
written_bytes Number of bytes written
total_rows_to_read Total rows to read

Note: available keys may vary by ClickHouse version. Older versions (< 22.x) may return zeros for write statistics.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views