A tool to profile mysql queries in php env.

Overview

MysqlQueryProfiler

This tool helps you to quickly profile a mysql query in a PHP 7.4+ environnement. You can also compare 2 queries.

116562521-85d11400-a903-11eb-85e6-c4dbe0ee42f9

This image shows the results when comparing 2 ip search queries ((A) BETWEEN + index vs (B) INTERSECTS + SPACIAL index):

  • left: query cost (SHOW STATUS...)
  • right: query plan (SHOW PROFILE...)
  • bottom: optimizer information (EXPLAIN...)

This is a standalone one file php script. Not dependency (vanilla js, css and standard php modules only).

Why use it?

It helps you to:

  • find mysql configuration issues
  • improve your indexes
  • improve your queries
  • spot mysql limitations

Features

  • Display the following reports:
    • query cost (SHOW STATUS...)
    • query plan (SHOW PROFILE...)
    • optimizer information (EXPLAIN...)
  • Compare 2 queries
  • Highlight the better values
  • Link to the mysql doc for status metric
  • Dark and light modes (prefers-color-scheme)
  • IP filtering

Usage

Use it only in DEV and control who can access it!

  1. Copy the file in a secure location (with .htaccess, etc.)
  2. Create a mysql user with profiling privileges.
  3. Configure the tool (user, password, ip allow list, etc.)

Usage within Docker

The following will create a PHP 7.4 container with the mysql query profiler and also a mariadb 10.4 container

docker-compose up -d

Open http://localhost/mysql_query_profiler.php in your web browser

To stop, run docker compose down

Integration

You may want to profile the queries generated by your application by clicking on a link from your web pages.

  1. In your main configuration file, add a constant that will allow you to turn on/off the query displaying. For example:
define('MQP_PROFILE_QUERIES', true);
  1. Copy-paste-adapt this code in a method where all your queries go through:
if (MQP_PROFILE_QUERIES) {
  echo '<div style="border:1px solid #ff9966;padding:5px;margin:5px">';
  echo '<a href="/mysql_query_profiler.php?query=' . urlencode($query) . '" target="mqp">';
  echo htmlspecialchars($query);
  echo '</a>';
  echo '</div>';
}
You might also like...
PHP Debug Console
PHP Debug Console

PHP Console A web console to try your PHP code into Creating a test file or using php's interactive mode can be a bit cumbersome to try random php sni

Php Debugger to run in terminal to debug your code easily.
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source lib to make a debug in php direct in terminal, without necessary configure an IDE. Th

PCOV - CodeCoverage compatible driver for PHP

PCOV A self contained CodeCoverage compatible driver for PHP Requirements and Installation See INSTALL.md API /** * Shall start recording coverage in

Low-overhead sampling profiler for PHP 7+
Low-overhead sampling profiler for PHP 7+

phpspy phpspy is a low-overhead sampling profiler for PHP. For now, it works with Linux 3.2+ x86_64 non-ZTS PHP 7.0+ with CLI, Apache, and FPM SAPIs.

The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function that you can use instead of var_dump().

VarDumper Component The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function t

PHP errors for cool kids
PHP errors for cool kids

whoops PHP errors for cool kids whoops is an error handler framework for PHP. Out-of-the-box, it provides a pretty error interface that helps you debu

Clockwork - php dev tools in your browser - server-side component
Clockwork - php dev tools in your browser - server-side component

Clockwork is a development tool for PHP available right in your browser. Clockwork gives you an insight into your application runtime - including requ

Laravel Debugbar (Integrates PHP Debug Bar)
Laravel Debugbar (Integrates PHP Debug Bar)

Laravel Debugbar This is a package to integrate PHP Debug Bar with Laravel. It includes a ServiceProvider to register the debugbar and attach it to th

This package connects a Laravel Octance application with Tideways for PHP Monitoring, Profiling and Exception Tracking.

Tideways Middleware for Laravel Octane This package connects a Laravel Octance application with Tideways for PHP Monitoring, Profiling and Exception T

Releases(v1.0.1)
  • v1.0.0(Apr 29, 2021)

    Features:

    • Display the following reports (query cost (SHOW STATUS...), query plan (SHOW PROFILE...), optimizer information (EXPLAIN...))
    • Compare 2 queries
    • Highlight the better values
    • Link to the mysql doc for status metric
    • Dark and light modes (prefers-color-scheme)
    • IP filtering
    • Font-size configuration
    • Charset configuration
    Source code(tar.gz)
    Source code(zip)
Owner
null
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
The ultimate debugging and development tool for ProcessWire

Tracy Debugger for ProcessWire The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS Integrates and extends Nette

Adrian Jones 80 Oct 5, 2022
Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

PHP Console server library PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things u

Sergey 1.4k Dec 25, 2022
PHP APM (Alternative PHP Monitor)

APM (Alternative PHP Monitor) APM (Alternative PHP Monitor) is a monitoring extension enabling native Application Performance Management (APM) for PHP

Patrick Allaert 310 Dec 4, 2022
Zipkin PHP is the official PHP Tracer implementation for Zipkin

Zipkin PHP is the official PHP Tracer implementation for Zipkin, supported by the OpenZipkin community. Installation composer require openz

Open Zipkin 250 Nov 12, 2022
Debug bar for PHP

PHP Debug Bar Displays a debug bar in the browser with information from php. No more var_dump() in your code! Features: Generic debug bar Easy to inte

Maxime Bouroumeau-Fuseau 4k Jan 8, 2023
Xdebug — Step Debugger and Debugging Aid for PHP

Xdebug Xdebug is a debugging tool for PHP. It provides step-debugging and a whole range of development aids, such as stack traces, a code profiler, fe

Xdebug 2.8k Jan 3, 2023
PHP Benchmarking framework

PHPBench is a benchmark runner for PHP analogous to PHPUnit but for performance rather than correctness. Features include: Revolutions: Repeat your co

PHPBench 1.7k Jan 2, 2023
The Interactive PHP Debugger

The interactive PHP debugger Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality

Joe Watkins 841 Oct 9, 2022
Dontbug is a reverse debugger for PHP

Dontbug Debugger Dontbug is a reverse debugger (aka time travel debugger) for PHP. It allows you to record the execution of PHP scripts (in command li

Sidharth Kshatriya 709 Dec 30, 2022