Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

OrzClick

PHP client for Yandex ClickHouse, powered by PHP-CPP and clickhouse-cpp.

Supported data types

  • Array(T)
  • Date
  • DateTime
  • Decimal(P,S), Decimal32, Decimal64, Decimal128
  • Enum8, Enum16
  • FixedString(N)
  • Float32, Float64
  • IPv4, IPv6
  • Nullable(T)
  • String
  • Tuple
  • UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64

Limitations:

  • Tuple can not nested in Array, eg, Array(Tuple(Int8, Int8)) is not supported
  • UInt64 are returen as Int64, since PHP doesn’t support 64-bits unsigned integer

Building

Prerequisite

  • clang >= 10, with lld as default linker
  • php >= 7.4
  • cmake

Run

./build.sh

Then you have liborzclick.so in build directory.

Example

$options = (newOrzClick\ClientOptions())
->setHost('127.0.0.1')
->setCompressionMethod(1)
->TcpNoDelay(true);
$client = newOrzClick\Client($options);
// Execute statement$client->execute('create table if not exists default.insert_demo ( id UInt32, arr Array(Int32)) Engine = Memory' );
// Column definition$columns = [
'id' => newOrzClick\ColumnUInt32(),
'arr' => newOrzClick\ColumnArray(newOrzClick\ColumnInt32),
];
// KV datafor ($i = 0; $i < 10; $i++) {
$data[] = [
'id' => $i,
'arr' => [$i , $i + 1]
];
}
$client->insert('default.insert_demo', $columns, $data);
// Columnar Datafor ($i = 0; $i < 10; $i++) {
$columnarData['id'][] = $i;
$columnarData['arr'][] = [$i, $i * 2];
}
$client->insertColumnar('default.insert_demo', $columns, $columnarData);

Benchmark (2020-10-06)

Select benchmark result (lower is better):

./bench/image/bench-select.png

Insert benchmark result (lower is better):

./bench/image/bench-insert.png

About

A fast Clickhouse client for PHP (build just for fun) https://learnku.com/articles/50419

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages