Product Decisions This Supports
- Build vs. buy for SQL performance tooling. This package wraps Xiaomi's SOAR (SQL Optimizer And Rewriter) in a PHP/Laravel-friendly API under MIT. It lets you evaluate an in-house "query review" capability in days rather than procuring a commercial database observability suite, and gives you a like-for-like baseline before you spend on one.
- Shift-left on performance as a roadmap bet. It turns SQL tuning from a reactive production incident into a pre-merge check: score a query, get index hints, see the execution plan, and catch full scans before they ship. That is a concrete DevEx investment you can scope, staff, and measure (e.g., number of slow-query regressions caught pre-release).
- Where to invest scarce DBA time. Automated advice handles the repeatable cases (missing index, implicit conversion, bad join order,
SELECT *); humans get routed the hard ones. This informs whether you hire a DBA, buy a managed service, or automate.
- Prioritizing database/performance debt. A numeric score plus explain output makes "this endpoint is slow because of this query" a comparable, trackable backlog item rather than a vague complaint — useful for quarterly planning and for arguing for index/schema migrations.
- Gating new analytics, reporting, and admin features. Any feature that lets product teams or customers write ad-hoc SQL (report builders, exports, dashboards) can be run through the analyzer as an advisory check before release.
- Query fingerprinting for triage. Grouping structurally identical queries supports decisions about caching layers, read replicas, and whether a "one-off slow query" is actually a systemic pattern.
- Vendor and lock-in posture. MIT-licensed, no per-query SaaS meter, and it composes with your existing Laravel stack — low switching cost if you later replace it.
When to Consider This Package
Consider it when:
- You run a PHP/Laravel stack on MySQL or MariaDB and want automated SQL review without leaving your existing tooling.
- You want a fast, cheap proof of concept: a service provider, facade, and config file get you scoring, syntax checks, explain output, and rewrite suggestions in JSON/Markdown/HTML, which you can wire into an Artisan command or CI job.
- You have no dedicated DBA, or DBA capacity is a bottleneck for routine query review.
- You want to avoid re-implementing binary management — the package handles invoking the SOAR binary so your team isn't writing Go tooling glue.
- You want advisory, human-in-the-loop tooling, not an enforcement gate, in the first iteration.
Look elsewhere when:
- You need production runtime monitoring, alerting, or APM (slow-query logs, live dashboards, regression alerts). This is a static/advisory analyzer, not an observability platform.
- You are Postgres- or multi-dialect-heavy. SOAR is MySQL-oriented; dialect coverage and rule quality will not map to your estate.
- You need a vendor-backed product with support, SLAs, and an audited supply chain. This is a small, single-maintainer-style OSS dependency (~196 stars) with an external Go binary in the critical path — a real diligence item for regulated or high-availability environments.
- You need guaranteed query rewriting enforced in production. Treat rewrite output as suggestions requiring review; auto-applying them is a risk decision, not a package feature.
- Your team cannot install or pin an external binary in CI/build images, or your platform standards forbid it.
- You need fine-grained rule customization with a stable, versioned rule API — you'd be inheriting SOAR's rule semantics and release cadence, not just the PHP wrapper's.
Practical diligence before adoption: confirm the release cadence and maintenance responsiveness, pin the SOAR binary version explicitly, and validate output quality against your own 20–50 worst real queries rather than the README examples.
How to Pitch It (Stakeholders)
For executives (one paragraph): We can add automated SQL performance review to our existing PHP workflow at essentially zero license cost, using a mature open-source analyzer (Xiaomi's SOAR) through a small MIT-licensed Laravel wrapper. It gives engineers instant feedback on query scores, missing indexes, execution plans, and rewrite suggestions before code ships — which targets the class of performance bugs that currently surface as production incidents and consume senior/DBA time. The proposal is a time-boxed pilot on one or two services, judged against a baseline of slow-query regressions and review turnaround; it is fully reversible and creates no vendor lock-in. Key caveat: it is advisory tooling, not production monitoring, and the dependency (small OSS project plus an external binary) needs a short risk sign-off.
For engineering: Drop-in Laravel integration (service provider, facade, config) with methods for syntax checking, scoring, explain, fingerprinting, and rewrite, exportable as JSON/Markdown/HTML — so it slots into an Artisan command or CI step without custom tooling. Scope the first iteration as a non-blocking report on changed queries in PRs, not a merge gate; pin the SOAR binary version; review the rewrite suggestions rather than applying them automatically; and benchmark against a curated set of our real slow queries before we commit to wider rollout.