search for standard sites pub-search.waow.tech
search zig blog atproto

add /check-perf command for logfire performance analysis

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+84
+84
.claude/commands/check-perf.md
··· 1 + # check performance via logfire 2 + 3 + use `mcp__logfire__arbitrary_query` with `age` in minutes (max 43200 = 30 days). 4 + 5 + note: `duration` is in seconds (DOUBLE PRECISION), multiply by 1000 for ms. 6 + 7 + ## latency percentiles by endpoint 8 + ```sql 9 + SELECT span_name, 10 + COUNT(*) as count, 11 + ROUND(PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY duration) * 1000, 2) as p50_ms, 12 + ROUND(PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY duration) * 1000, 2) as p95_ms, 13 + ROUND(PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY duration) * 1000, 2) as p99_ms 14 + FROM records 15 + WHERE span_name LIKE 'http.%' 16 + GROUP BY span_name 17 + ORDER BY count DESC 18 + ``` 19 + 20 + ## slow requests with trace IDs 21 + ```sql 22 + SELECT span_name, duration * 1000 as ms, trace_id, start_timestamp 23 + FROM records 24 + WHERE span_name LIKE 'http.%' AND duration > 0.1 25 + ORDER BY duration DESC 26 + LIMIT 20 27 + ``` 28 + 29 + ## trace breakdown (drill into slow request) 30 + ```sql 31 + SELECT span_name, duration * 1000 as ms, message, attributes->>'sql' as sql 32 + FROM records 33 + WHERE trace_id = '<TRACE_ID>' 34 + ORDER BY start_timestamp 35 + ``` 36 + 37 + ## database comparison (turso vs local) 38 + ```sql 39 + SELECT 40 + CASE WHEN span_name = 'db.query' THEN 'turso' 41 + WHEN span_name = 'db.local.query' THEN 'local' END as db, 42 + COUNT(*) as queries, 43 + ROUND(AVG(duration) * 1000, 2) as avg_ms, 44 + ROUND(MAX(duration) * 1000, 2) as max_ms 45 + FROM records 46 + WHERE span_name IN ('db.query', 'db.local.query') 47 + GROUP BY db 48 + ``` 49 + 50 + ## recent errors 51 + ```sql 52 + SELECT start_timestamp, span_name, exception_type, exception_message 53 + FROM records 54 + WHERE exception_type IS NOT NULL 55 + ORDER BY start_timestamp DESC 56 + LIMIT 10 57 + ``` 58 + 59 + ## traffic pattern (requests per minute) 60 + ```sql 61 + SELECT date_trunc('minute', start_timestamp) as minute, 62 + COUNT(*) as requests 63 + FROM records 64 + WHERE span_name LIKE 'http.%' 65 + GROUP BY minute 66 + ORDER BY minute DESC 67 + LIMIT 30 68 + ``` 69 + 70 + ## search query distribution 71 + ```sql 72 + SELECT attributes->>'query' as query, COUNT(*) as count 73 + FROM records 74 + WHERE span_name = 'http.search' AND attributes->>'query' IS NOT NULL 75 + GROUP BY query 76 + ORDER BY count DESC 77 + LIMIT 20 78 + ``` 79 + 80 + ## typical workflow 81 + 1. run latency percentiles to get baseline 82 + 2. if p95/p99 high, find slow requests with trace IDs 83 + 3. drill into specific trace to see which child spans are slow 84 + 4. check db comparison to see if turso calls are the bottleneck