Performance
Skill professor93/laravel-filament-claude/skills/performance
Use when a Filament panel is slow — slow tables, slow dashboards/widgets, slow search or sort, high query counts (N+1), slow pagination on big tables, memory blowups on bulk actions or exports — or when asked to optimize SQL/Eloquent queries, add database indexes, cache widget data, or profile a Laravel/Filament app. Also before shipping any table over ~100k rows.From its SKILL.md
npx -y skills add professor93/laravel-filament-claude --skill performanceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.4 KB, as published. Nobody here has run it
Filament Performance & Query Optimization
Triage first — Filament slowness has three distinct causes. Fixing the wrong one wastes days:
| Symptom shape | Cause | Where to look |
|---|---|---|
| Slow with FEW rows, many actions/columns | Render-bound (Blade view includes, Livewire payload) | rows-per-page, action count, partial rendering — below |
| Query count grows with row count | N+1 | eager-loading boundary — references/query-lifecycle.md |
| Slow with clean query count | SQL-bound (missing index, COUNT(*), wildcard search, relationship sort) | references/indexing.md |
Diagnose before fixing: references/diagnosis.md (Debugbar's Livewire dropdown, Telescope,
Pulse, DB::whenQueryingForLongerThan()). Beware: Debugbar's views collector itself
makes Filament look slow — disable it ('collectors' => ['views' => false]) before
trusting any measurement.
The highest-leverage moves (in order)
- Kill the pagination COUNT(*) on big filtered tables:
->paginationMode(PaginationMode::Simple)and remove'all'from->paginated([...])(picking "all" reruns the count — verified in Filament source). Cursor mode for infinite-scroll-style feeds. - Fix the eager-loading boundary. Filament auto-eager-loads ONLY dot-notation column
names (
author.name) — every relationship touched inside->state(),->formatStateUsing(),->description(),->url(),->tooltip(), action->visible()/policies, and custom views is YOUR job:->modifyQueryUsing(fn (Builder $q) => $q->with([...])->withCount([...])). - Index what the table actually does: composite
(tenant/status equality columns …, sort column last); every->searchable()/->sortable()/filter column reviewed. Migrations ship in the same PR as the panel change. references/indexing.md. - Replace wildcard LIKE search where it hurts:
->searchable(query: fn (Builder $q, string $search) => $q->whereFullText([...], $search))(or pg_trgm) — Filament's default isLIKE '%term%'(leading wildcard, unindexable; on PostgreSQL additionally wrapped inlower()). - Fix relationship-column sorting at scale:
->sortable()onauthor.nameemits a correlatedORDER BY (SELECT … LIMIT 1)subquery per row. Use->sortable(query: fn (Builder $q, string $direction) => $q->orderBy(...))with a join or denormalized column.->defaultKeySort(false)when the implicit PK tiebreaker defeats your index. - Silence dashboard polling. Stats/chart widgets poll every 5s by default —
protected ?string $pollingInterval = null;is near-reflex (each widget × each open tab is a full Livewire round trip).
Tables — the checklist
->deferLoading()on heavy tables (tests then needloadTable()first).- Default filters that bound the initial query (e.g. current month) — on million-row tables the DB, not Filament, is usually the bottleneck.
whereDate()/whereYear()in filters kill indexes — use half-open ranges:->where('created_at', '>=', $start)->where('created_at', '<', $end).- Aggregate columns:
TextColumn::make('users_count')->counts('users')(SQL subselect) — never$record->users()->count()in a closure. Each aggregate column is a correlated subselect per row: fine at 25/page, not with huge page sizes. - Row/action density is render cost: prefer 10-50 rows/page, group actions, avoid rendering many custom ViewColumns.
- Options closures: never
Model::all()/unboundedpluck()—->relationship()with->searchable()(server-side search) and->preload()only for genuinely small sets.
Widgets & dashboards
- Reuse the list page's already-filtered query for resource stats:
use InteractsWithPageTable;+getTablePage(): string+$this->getPageTableQuery(). - One query, not N: replace per-category count loops with
GROUP BYselects; multiple aggregates in one query (COUNT,SUM(CASE …)); cross-table totals via UNION ALL. - Trend/chart data:
flowframe/laravel-trendgroups by a DB date function — index the date column (the WHERE range still uses it) and mind timezones (buckets use the DB session tz). Chart date-bucketing belongs in SQL, never PHP collection grouping over full tables. - Cache expensive stats:
Cache::flexible('kpi', [60, 600], fn () => …)(serve stale, refresh after response) ·#[Computed(persist: true, seconds: 3600)]on custom pages ·Cache::memo()for repeated reads inside one request. Notags:on#[Computed]. - Widgets are lazy by default (
$isLazy) — never hand-rollwire:initloaders. - Big custom pages: Livewire 4
@island(lazy: true)regions render independently.
Bulk actions, exports, jobs
->chunkSelectedRecords(250)bounds memory;->fetchSelectedRecords(false)passes IDs only — but skips per-record policies AND model events (security/behavior tradeoff, say so when using it).- Iterating big sets in jobs/exports:
lazyById(200)(safe with eager loads + mutation);cursor()cannot eager-load and PDO buffers anyway — preferlazyById. - Queue heavy work; Filament's Import/Export actions are queued and chunked already — don't rebuild them.
Strictness — the N+1 tripwire
// AppServiceProvider::boot()
Model::preventLazyLoading(! app()->isProduction());
Model::handleLazyLoadingViolationUsing( // log-don't-throw on staging
fn ($model, $relation) => report(new LazyLoadingViolationException($model, $relation)));
Filament trips it in known places (global search details, actions on View pages
re-resolving records, relation managers) — each has an eager-load fix in
references/query-lifecycle.md. Model::automaticallyEagerLoadRelationships() (Laravel
12.8+) is the blanket fallback; explicit ->with() beats it on hot paths.
Production
php artisan filament:optimize + php artisan optimize + OPcache (filament:panels →
production reference). Never publish Filament Blade views for customization — every
internal rendering optimization bypasses published views; use CSS hooks instead.