halilcosdu/laravel-slower
Laravel Slower captures your slowest database queries and uses AI (OpenAI, Claude, Gemini, or custom models) to suggest indexes and rewrites, with a built-in dashboard at /slower and no frontend setup.
Architecture fit. Laravel Slower is a developer-tooling add-on that sits in the same architectural slot as Telescope and Horizon: a package-owned route group, a published migration into the host application's database, a service-provider-registered DB::listen hook, and a gate (viewSlower) controlling access. It imposes no abstraction on application code — nothing to extend, no interfaces in your domain, no changes to models or queries. That is the right shape for this class of tool: the blast radius of adoption is a service provider, one table, and a config file. The substantive architectural coupling is outward: query capture flows to an optional third-party LLM through Prism (the Laravel AI package), so the package effectively extends your data-processing perimeter to an external provider. That is an architecture decision, not a package decision, and it is the one item a TPM must escalate rather than decide.
Integration feasibility. Very high on the mechanical axis. composer require, publish migrations, migrate, open /slower — minutes to first value in a local environment, with no npm, CDN, or asset publishing. Config is env-driven and optional. The dashboard reuses the Telescope/Horizon authorization idiom, so it will be immediately legible to any Laravel team. Realistic effort is half a day for a correct non-local rollout (threshold tuning, sample rate, gate definition, queue worker, retention schedule, secrets) plus whatever security/legal review the AI payload triggers. There is no migration of existing data; the only backfill is slower:fingerprint, which is chunked and idempotent.
Technical risk.
EXPLAIN plan — the last of which the README explicitly warns may echo literals on some drivers. Schema names are themselves disclosure (patient_records, billing_tokens). In a regulated environment this requires a provider DPA, a documented redactor implementing PayloadRedactor, and possibly a self-hosted model via the custom driver to keep traffic in-VPC.slow_logs accumulates SQL and bindings containing PII and secrets in your primary database. This is a new regulated data store with no encryption or access control beyond the gate. Retention is an operator responsibility.analyze_pending_limit (10) at once." Ten sequential 30-second LLM round-trips inside an HTTP request is a request-timeout incident. Queued analysis must be treated as mandatory, not optional, in any shared environment.DB::listen is a global hook; stacking it with Telescope, Pulse, and Debugbar means several listeners holding resolved SQL and bindings per query. Overhead is per-query, not per-slow-query.max_per_execution deliberately make counts approximate. A dashboard showing partial data with no visible "sampled" badge is a decision-support hazard.Key questions.
slow_logs connection configurable so it can target a separate database, or does it always write to the default connection?SLOWER_MAX_PER_EXECUTION inside long-lived queue:work and Octane processes — the job/request, or the process lifetime?EXPLAIN ANALYZE (which executes on Postgres), or strictly non-executing EXPLAIN? On which connection and with what privileges?slower:clean ship scheduled, or must the operator wire it into routes/console.php?viewSlower gate cover every dashboard route, including AJAX/JSON endpoints used by the Analyze and delete actions?Stack fit. Native. PHP 8.3+ and Laravel 11–13 covers any actively maintained codebase; the package assumes only what every Laravel app already has (a database, an artisan console, optionally a queue). For teams already running Horizon, the gate pattern and /slower path will feel like an extension of existing tooling rather than a new platform. The custom-driver escape hatch is the differentiator for enterprise: it converts a "send our schema to OpenAI" conversation into a "point at our approved inference endpoint" conversation.
Migration path. Purely additive — no changes to application code, no schema changes to existing tables. Adoption is composer require → publish and run the migration → publish config only if defaults need overriding → define the gate → schedule slower:analyze and slower:clean. Removal is symmetric: disable routes via SLOWER_DASHBOARD_ENABLED=false, drop slow_logs, remove the provider entry from config/app.php. Back out cost is near zero, which is the strongest argument for running a bounded pilot rather than a committee review.
Compatibility. Check three edges before committing: (a) coexistence with Telescope/Pulse/Debugbar listeners in the same environment; (b) MySQL vs Postgres EXPLAIN semantics and privileges for the app's DB user; (c) the existing observability surface — if the team already runs Pulse or an APM with slow-query capture, Slower must be positioned as the remediation layer (fingerprinted grouping + origin + AI suggestion), not a replacement for metrics, or it becomes a redundant tab nobody opens.
Sequencing.
slow_logs. If this stalls, proceed to step 3 anyway with AI disabled — capture and grouping retain most of the value.SLOWER_ANALYZE_QUEUE set, SLOWER_SAMPLE_RATE tuned to observed slow-query volume, gate restricted to a named engineer group, slower:clean --days=30 scheduled.SlowQueryFirstSeen to the team channel so new query shapes surface without anyone visiting the dashboard.Maintenance. Low and bounded. The code surface is small and conventional; upgrades are Composer bumps gated on Laravel/PHP version alignment and, on fingerprint-algorithm changes, a re-run of slower:fingerprint. The real recurring work is database hygiene: slow_logs growth, index maintenance on that table, and keeping the retention job alive. Budget roughly 0.1 FTE for the first quarter, falling after that, plus the standing cost of monitoring a single-maintainer dependency for abandonment signals.
Support. No commercial backing and no SLA. Support is GitHub issues plus a thorough README and changelog. In practice the README's privacy and production-control sections are strong enough that most questions are self-service. The compensating control for bus factor is license and size: MIT plus a small, readable codebase means a fork is a day of work, not a quarter. Keep the dependency pinned and record the fork decision in the runbook.
Scaling. Two independent axes. Storage: captured rows scale as requests × slow-query fraction × sample rate; on a high-QPS system this is the binding constraint and the reason SLOWER_SAMPLE_RATE and slower:clean are not optional. Writing that volume to the primary database is write amplification you are choosing to accept — verify whether a separate connection is configurable before assuming you can isolate it. AI spend: cost scales with analyzed queries, controllable via analyze_pending_limit, nightly batching instead of button-driven analysis, and analyzing grouped shapes rather than individual events so one LLM call covers 10,000 occurrences.
Failure modes and mitigations.
slow_logs write failure (full disk, dropped table) → the built-in circuit breaker backs off 60 seconds and still report()s; confirm this path is alarmed, since a silently tripped breaker means no data.max_per_execution on runaway jobs → document that counts are approximate; alert if the cap trips repeatedly, which itself indicates a query-in-a-loop defect.slower:fingerprint as a release step, and expect the Grouped view to reshuffle temporarily.Ramp-up. Nearly flat for an engineer already fluent in Laravel: the mental model is Telescope plus a /slower page, and the origin table (route / job / command / file:line) makes recommendations concrete enough that a mid-level developer can act on them without an APM expert. Time to competent use is under a day. The real ramp-up risk is organizational, not technical — the package is an opinionated prompt for a remediation habit, and if no one owns the weekly triage, adoption decays into an unused dashboard with a growing table. Assign the owner before installation, not after.
How can I help you explore Laravel packages today?