几天内即可获得 Laravel 代码审查方面的专家指导

Laravel ClickHouse: A Full-Featured ClickHouse Driver for Laravel

发布日期 经过

Laravel ClickHouse: A Full-Featured ClickHouse Driver for Laravel image

Laravel ClickHouse is a database driver that integrates ClickHouse with Laravel, including Eloquent, the Query Builder, Schema Builder, and more:

  • Eloquent models with non-incrementing ID support
  • Query Builder with ClickHouse-specific clauses (i.e., FINAL , ARRAY JOIN , SAMPLE
  • Schema Builder with ENGINE , PARTITION BY , ORDER BY , 和 LowCardinality column types
  • Laravel migration support via artisan migrate
  • Concurrent query execution using Guzzle's async HTTP pool
  • Dual HTTP transport options: Guzzle and Curl/phpclickhouse

ClickHouse is an open-source column-oriented database built for analytical workloads. It stores data by column rather than by row, making aggregations over large datasets fast—capable of querying billions of rows in seconds. It's a common choice for event tracking, time-series data, and analytics dashboards where read performance at scale is the priority.

Eloquent 模型

You can define Eloquent models pointing at ClickHouse the same way you would for any other database connection:

班级 事件 延伸 模型
{
受保护 $连接 = 'clickhouse' ;
}
$事件 = 事件 :: 在哪里 '用户身份' , 1 -> 得到 ();

ClickHouse doesn't use auto-incrementing primary keys, so the driver configures models with non-incrementing IDs by default. Scopes and collections work as expected.

Query Builder with ClickHouse Extensions

The Query Builder covers standard Laravel methods and adds ClickHouse-specific clauses. The final parameter applies the FINAL modifier to a query, which forces ClickHouse to merge duplicate rows at read time—useful with the ReplacingMergeTree engine:

$事件 = 数据库 :: 联系 'clickhouse'
-> 桌子 “事件” , 最终的 : 真的
-> 在哪里 '用户身份' , 1
-> 得到 ();

Other extensions include PREWHERE (ClickHouse's pre-filter for primary key columns), ARRAY JOIN , SAMPLE , LIMIT BY , 和 SEMI / ANTI / ASOF join types.

Schema Builder and Migrations

The Schema Builder supports ClickHouse DDL via a ClickHouseBlueprint , letting you define table engines, partition keys, order keys, and column types like LowCardinality :

架构 :: 联系 'clickhouse' -> 创造 “事件” , 功能 ClickHouseBlueprint $table) {
$表 -> 引擎 'MergeTree()' (英文):
$表 -> orderBy ([ 'ID' , 'created_at' ]);
$表 -> partitionBy 'toYYYYMM(created_at)' (英文):
});

标准 artisan migrate commands work with a ClickHouse-compatible migration repository, so you can manage schema changes alongside your other databases.

Concurrent Query Execution

The package includes a Parallel helper that runs multiple queries at the same time using Guzzle's async HTTP pool:

$结果 = 平行线 :: 得到 ([
“用户” => 用户 :: 在哪里 '积极的' , 1 ),
“事件” => 事件 :: 在哪里 '类型' , '点击' ),
]);

两个都 usersevents execute concurrently, and the results are returned as a keyed array once all queries resolve.

You can find the full documentation and source on GitHub

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
Laravel 代码审查

几天内即可获得 Laravel 代码审查方面的专家指导

访问 Laravel 代码审查
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
Laravel Installer Now Returns JSON When Running Inside an AI Agent image

Laravel Installer Now Returns JSON When Running Inside an AI Agent

阅读文章
Queue-Wide Inspection Methods in Laravel 13.8.0 image

Queue-Wide Inspection Methods in Laravel 13.8.0

阅读文章
Verifiable Audit Logging with Laravel Chronicle image

Verifiable Audit Logging with Laravel Chronicle

阅读文章
Ship AI with Laravel: Search Entire PDFs with Zero Search Logic image

Ship AI with Laravel: Search Entire PDFs with Zero Search Logic

阅读文章
Personalized Content Delivery System: Building an AI-powered recommendation engine with Laravel and MongoDB image

Personalized Content Delivery System: Building an AI-powered recommendation engine with Laravel and MongoDB

阅读文章
Laravel Brain: Visualize Your Application's Request Lifecycle image

Laravel Brain: Visualize Your Application's Request Lifecycle

阅读文章