定制 phpfui/mysql-slow-log-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

PHPFUI/InstaDoc

License

Distributed under the MIT License.

统计信息

  • 总下载量: 303
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固