定制 tpetry/laravel-mysql-explain 二次开发

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

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

tpetry/laravel-mysql-explain

最新稳定版本:2.1.0

Composer 安装命令:

composer require tpetry/laravel-mysql-explain

包简介

Get Visual MySQL EXPLAIN for Laravel.

README 文档

README

License PHP Laravel Latest Version on Packagist GitHub Unit Tests Action Status GitHub Static Analysis Action Status GitHub Code Style Action Status

MySQL Query optimization with the EXPLAIN command is unnecessarily complicated: The output contains a lot of cryptic information that is incomprehensible or entirely misleading.

This Laravel package collects many query metrics that will be sent to mysqlexplain.com and transformed to be much easier to understand.

Installation

You can install the package via composer:

composer require tpetry/laravel-mysql-explain

Usage

Query Builder

Three new methods have been added to the query builder for very easy submission of query plans:

Type Action
visualExplain returns URL to processed EXPLAIN output
dumpVisualExplain dumps URL to processed EXPLAIN output and continue normal execution
ddVisualExplain dumps URL to processed EXPLAIN output and stops execution
explainForHumans (deprecated) returns URL to processed EXPLAIN output
dumpExplainForHumans (deprecated) dumps URL to processed EXPLAIN output and continue normal execution
ddExplainForHumans (deprecated) dumps URL to processed EXPLAIN output and stops execution
// $url will be e.g. https://mysqlexplain.com/explain/01j2gcrbsjet9r8rav114vgfsy
$url = Film::where('description', 'like', '%astronaut%')
    ->visualExplain();

// URL to EXPLAIN will be printed to screen
$users = Film::where('description', 'like', '%astronaut%')
    ->dumpVisualExplain()
    ->get();

// URL to EXPLAIN will be printed to screen & execution is stopped
Film::where('description', 'like', '%astronaut%')
    ->ddVisualExplain();

Raw Queries

In some cases you are executing raw SQL queries and don't use the query builder. You can use the MysqlExplain facade to get the EXPLAIN url for them:

use Tpetry\LaravelMysqlExplain\Facades\MysqlExplain;

// $url will be e.g. https://mysqlexplain.com/explain/01j2gctgtheyva7a7mhpv8azje
$url = MysqlExplain::submitQuery(
    DB::connection('mysql'),
    'SELECT * FROM actor WHERE first_name = ?',
    ['PENEL\'OPE'],
);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 144.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 263
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 263
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固