PHPackages                             danieljharvey/stinky-query-finder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. danieljharvey/stinky-query-finder

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

danieljharvey/stinky-query-finder
=================================

Find stinky queries

06PHP

Since Jun 2Pushed 8y agoCompare

[ Source](https://github.com/danieljharvey/stinky-query-finder)[ Packagist](https://packagist.org/packages/danieljharvey/stinky-query-finder)[ RSS](/packages/danieljharvey-stinky-query-finder/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

stinky-query-finder
===================

[](#stinky-query-finder)

Find what will probably turn out to be totally awful MySQL queries before they ruin everything. [![Build Status](https://camo.githubusercontent.com/270a18dbe5e46dcb32f6be6810dce15bdbe7a80809d1014d9af73d56edc73178/68747470733a2f2f7472617669732d63692e6f72672f64616e69656c6a6861727665792f7374696e6b792d71756572792d66696e6465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/danieljharvey/stinky-query-finder)

**What does it do then?**

You pass it a PDO object and a SQL call, it learns a little about your DB, and works out whether your query is potentially garbage

**How does it decide?**

Basically, by whether a) the table is very long - if it's not, it'll be fine. b) if the table IS long, whether the query is using one or more indexes to give it a fighting chance of being OK.

**How do I use it?**

Make a PDO object, pass it into a nice new Stinkers object, and ask it whether your SQL is dogshit or not.

```
$dbName = "greatDB"

$dsn = "mysql:dbname={$dbName};host=127.0.0.1";

$pdo = new \PDO($dsn, "username", "excellentPassword");

$sql = "SELECT COUNT(1) FROM excellentTable WHERE thingID=2229 AND theDate='2017-05-12'";

$stinkers = new \DanielJHarvey\QueryStinkers\Stinkers($dbName, $tables, $pdo);

$problematicQuery = $stinkers->checkQuery($sql);

```

$problematicQuery will either return false (not a problem, great) or an array-based stack trace (so that the offending query creating code can be located)

**That's going to slow things down a bit isn't it?**

Yeah, unfortunately so, so please please please don't use this in production. If you wish to speed things up, you can cache the DB tables data created by Stinkers like this:

```

$tables = $stinkers->getTables();

cacheTablesDataWithYourExcellentCachingSolution($tables);

```

Then you're free to use it again like this:

```

$dbName="excellentDB"
$tables = getCachedTablesFromYourGreatCachingFunction();

$stinkers = new \DanielJHarvey\QueryStinkers\Stinkers($dbName, $tables);

// no need to rebuild table data, everything is fine

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/93fbc523207f38cbe06a394df6770ff393426bd24237e82c477da30e1b673af1?d=identicon)[danieljharvey](/maintainers/danieljharvey)

---

Top Contributors

[![danieljharvey](https://avatars.githubusercontent.com/u/4729125?v=4)](https://github.com/danieljharvey "danieljharvey (9 commits)")

### Embed Badge

![Health badge](/badges/danieljharvey-stinky-query-finder/health.svg)

```
[![Health](https://phpackages.com/badges/danieljharvey-stinky-query-finder/health.svg)](https://phpackages.com/packages/danieljharvey-stinky-query-finder)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
