phpfui/mysql-slow-log-parser
Composer 安装命令:
composer require phpfui/mysql-slow-log-parser
包简介
MySQL and MariaDB Slow Query Log Parser featuring sortable results
README 文档
README
PHP Parser for MySQL and MariaDB Slow Query Logs featuring sortable results
Requirements
- Modern PHP version
- MySQL 5.7 or higher, or MariaDB
Usage
$parser = new \PHPFUI\MySQLSlowQuery\Parser($logFilePath); // Return the sessions in the file as array $sessions = $parser->getSessions(); // Return all entries in file as array, or pass session number (0 based) $entries = $parser->getEntries(); if (count($entries)) { // Get the worst offender $entry = $parser->sortEntries()->getEntries()[0]; echo 'Query ' . implode(' ', $entry->Query) . " took {$entry->Query_time} seconds at {$entry->Time}\n"; // Get the most rows examined $entry = $parser->sortEntries('Rows_examined', 'desc')->getEntries()[0]; echo 'Query ' . implode(' ', $entry->Query) . " looked at {$entry->Rows_examined} rows\n"; }
Entries
\PHPFUI\MySQLSlowQuery\Entry provides details on each query. Supported fields:
- Time
- User
- Host
- Id
- Query_time
- Lock_time
- Rows_sent
- Rows_examined
- Query (array)
- Session (zero based)
MariaDB adds the following fields:
- Thread_id
- Schema
- QC_hit
- Rows_affected
- Bytes_sent
- Tmp_tables
- Tmp_disk_tables
- Tmp_table_sizes
- Full_scan
- Full_join
- Tmp_table
- Tmp_table_on_disk
- Filesort
- Filesort_on_disk
- Merge_passes
- Priority_queue
- explain
Sessions
\PHPFUI\MySQLSlowQuery\Session contains MySQL server information and are created on server restarts and log flushes. Pass the zero based session number to getEntries for only that Session's entries. Supported fields:
- Server
- Version
- Port
- Transport
Sort Entries
By default, entries are returned in log order, but call sortEntries on the Parser to sort by any valid field (parameter 1). Sort defaults to 'desc', anything else will sort ascending.
Full Class Documentation
License
Distributed under the MIT License.
phpfui/mysql-slow-log-parser 适用场景与选型建议
phpfui/mysql-slow-log-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 303 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「log」 「parser」 「mysql」 「query」 「mariadb」 「slow」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpfui/mysql-slow-log-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpfui/mysql-slow-log-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpfui/mysql-slow-log-parser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
An MT940 bank statement parser for PHP
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Laravel 5.x.x library for integration Monolog Sentry
Laravel integration for the jsonapi.org parser
统计信息
- 总下载量: 303
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-04