{"data":{"slug":"discovered-9db3970ceae9f4205da5dfddb339ada5033c41bd38b036c1","title":"Performance Patterns","summary":"Optimize app performance by applying database indexing, API compression, memory streaming, and other proven techniques. Deliverables include optimized code and performance improvement metrics.","url":"https:\/\/skillshunter.net\/skills\/discovered-9db3970ceae9f4205da5dfddb339ada5033c41bd38b036c1","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-9db3970ceae9f4205da5dfddb339ada5033c41bd38b036c1","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-9db3970ceae9f4205da5dfddb339ada5033c41bd38b036c1.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-9db3970ceae9f4205da5dfddb339ada5033c41bd38b036c1\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Measure performance first using profiling tools to identify bottlenecks. Ensure environment supports Redis for caching and Node.js or PHP for specific implementations.","instructions":"---\nname: performance-patterns\nversion: 1.0.0\n---\n\n# Performance Patterns\n\n**Invoke when app is slow or needs optimization.**\n\n## Universal Patterns\n\n### Database\n- **Index** frequently queried columns\n- **Eager load** relationships (avoid N+1)\n- **Paginate** large result sets\n- **Cache** expensive queries (Redis, 15min TTL)\n- **Chunk** batch operations (100-500 per batch)\n\n### API\n- **Compress** responses (gzip\/brotli)\n- **Cache** with ETags \/ Last-Modified\n- **Paginate** list endpoints\n- **Select only needed fields** (no `SELECT *`)\n\n### Memory\n- **Stream** large files (don't load into memory)\n- **Release** references in loops\n- **Monitor** memory usage in long-running processes\n\n## PHP Specific\n\n```php\n\/\/ \u274c N+1 problem\n$users = User::all();\nforeach ($users as $user) {\n    echo $user->posts->count(); \/\/ Query per user!\n}\n\n\/\/ \u2705 Eager loading\n$users = User::with('posts')->get();\n\n\/\/ \u2705 Chunked processing\nUser::where('active', true)->chunkById(100, function ($users) {\n    foreach ($users as $user) {\n        ProcessUserJob::dispatch($user);\n    }\n});\n```\n\n## React Specific\n\n```tsx\n\/\/ \u274c New object every render\n<Component style={{ color: 'red' }} \/>\n\n\/\/ \u2705 Memoized\nconst style = useMemo(() => ({ color: 'red' }), []);\n\n\/\/ \u2705 Lazy loading\nconst HeavyChart = lazy(() => import('.\/HeavyChart'));\n\n\/\/ \u2705 Virtualization for long lists\nimport { useVirtualizer } from '@tanstack\/react-virtual';\n```\n\n## Rules\n\n1. **MEASURE FIRST** \u2014 don't optimize blindly\n2. **PROFILE** \u2014 identify the actual bottleneck\n3. **ONE CHANGE AT A TIME** \u2014 isolate improvements\n4. **BENCHMARK** \u2014 before and after metrics\n","use_cases":["Optimize slow database queries by adding indexes and using eager loading","Reduce API response size with compression and selective field selection","Improve memory usage by streaming large files and releasing references"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/0x57-1\/start-vibing-stacks\/blob\/6e398b34c4dfe73ac8f809216b218856b8e02ff4\/stacks\/_shared\/skills\/performance-patterns\/SKILL.md","source_commit":"6e398b34c4dfe73ac8f809216b218856b8e02ff4","license":null,"version":null,"listing_approved_at":"2026-12-03","created_at":"2026-12-02T09:11:35.000000Z","updated_at":"2026-12-03T16:20:08.000000Z","seo_title":"Performance Optimization Patterns for Apps","seo_description":"Apply database indexing, API compression, and memory management techniques to improve app performance. Includes PHP and React-specific examples.","seo_keywords":["performance optimization","database indexing","API compression","memory management","PHP performance","React performance"]}}