[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-2924d8c1-c17a-44e7-9241-a87aba639f23":3,"$fSkezW3FY4ZqcPtQgAK2l_I9olsxutDkSUH2xgvySNng":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"2924d8c1-c17a-44e7-9241-a87aba639f23","odoo-performance-tuner","专家指南：诊断和修复Odoo性能问题：慢查询、工作进程配置、内存限制、PostgreSQL调优和性能分析工具。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: odoo-performance-tuner\ndescription: \"Expert guide for diagnosing and fixing Odoo performance issues: slow queries, worker configuration, memory limits, PostgreSQL tuning, and profiling tools.\"\nrisk: safe\nsource: \"self\"\n---\n\n# Odoo Performance Tuner\n\n## Overview\n\nThis skill helps diagnose and resolve Odoo performance problems — from slow page loads and database bottlenecks to worker misconfiguration and memory bloat. It covers PostgreSQL query tuning, Odoo worker settings, and built-in profiling tools.\n\n## When to Use This Skill\n\n- Odoo is slow in production (slow page loads, timeouts).\n- Getting `MemoryError` or `Worker timeout` errors in logs.\n- Diagnosing a slow database query using Odoo's profiler.\n- Tuning `odoo.conf` for a specific server spec.\n\n## How It Works\n\n1. **Activate**: Mention `@odoo-performance-tuner` and describe your performance issue.\n2. **Diagnose**: Share relevant log lines or config and receive a root cause analysis.\n3. **Fix**: Get exact configuration changes with explanations.\n\n## Examples\n\n### Example 1: Recommended Worker Configuration\n\n```ini\n# odoo.conf — tuned for a 4-core, 8GB RAM server\n\nworkers = 9                   # (CPU_cores × 2) + 1 — never set to 0 in production\nmax_cron_threads = 2          # background cron jobs; keep ≤ 2 to preserve user-facing capacity\nlimit_memory_soft = 1610612736  # 1.5 GB — worker is recycled gracefully after this\nlimit_memory_hard = 2147483648  # 2.0 GB — worker is killed immediately; prevents OOM crashes\nlimit_time_cpu = 600          # max CPU seconds per request\nlimit_time_real = 1200        # max wall-clock seconds per request\nlimit_request = 8192          # max requests before worker recycles (prevents memory leaks)\n```\n\n### Example 2: Find Slow Queries with PostgreSQL\n\n```sql\n-- Step 1: Enable pg_stat_statements extension (run once as postgres superuser)\nCREATE EXTENSION IF NOT EXISTS pg_stat_statements;\n\n-- Step 2: Also add to postgresql.conf and reload:\n-- shared_preload_libraries = 'pg_stat_statements'\n-- log_min_duration_statement = 1000   -- log queries taking > 1 second\n\n-- Step 3: Find the top 10 slowest average queries\nSELECT\n    LEFT(query, 100) AS query_snippet,\n    round(mean_exec_time::numeric, 2) AS avg_ms,\n    calls,\n    round(total_exec_time::numeric, 2) AS total_ms\nFROM pg_stat_statements\nORDER BY mean_exec_time DESC\nLIMIT 10;\n\n-- Step 4: Check for missing indexes causing full table scans\nSELECT schemaname, tablename, attname, n_distinct, correlation\nFROM pg_stats\nWHERE tablename = 'sale_order_line'\n  AND correlation \u003C 0.5   -- low correlation = poor index efficiency\nORDER BY n_distinct DESC;\n```\n\n### Example 3: Use Odoo's Built-In Profiler\n\n```text\nPrerequisites: Run Odoo with ?debug=1 in the URL to enable debug mode.\n\nMenu: Settings → Technical → Profiling\n\nSteps:\n  1. Click \"Enable Profiling\" — set a duration (e.g., 60 seconds)\n  2. Navigate to and reproduce the slow action\n  3. Return to Settings → Technical → Profiling → View Results\n\nWhat to look for:\n  - Total SQL queries > 100 on a single page  → N+1 query problem\n  - Single queries taking > 100ms             → missing DB index\n  - Same query repeated many times            → missing cache, use @ormcache\n  - Python time high but SQL low             → compute field inefficiency\n```\n\n## Best Practices\n\n- ✅ **Do:** Use `mapped()`, `filtered()`, and `sorted()` on in-memory recordsets — they don't trigger additional SQL.\n- ✅ **Do:** Add PostgreSQL B-tree indexes on columns frequently used in domain filters (`partner_id`, `state`, `date_order`).\n- ✅ **Do:** Enable Odoo's HTTP caching for static assets and put a CDN (Cloudflare, AWS CloudFront) in front of the website.\n- ✅ **Do:** Use `@tools.ormcache` decorator on methods pulled repeatedly with the same arguments.\n- ❌ **Don't:** Set `workers = 0` in production — single-threaded mode serializes all requests and blocks all users on any slow operation.\n- ❌ **Don't:** Ignore `limit_memory_soft` — workers exceeding it are recycled between requests; without the limit they grow unbounded and crash.\n- ❌ **Don't:** Directly manipulate `prefetch_ids` on recordsets — rely on Odoo's automatic batch prefetching, which activates by default.\n\n## Limitations\n\n- PostgreSQL tuning (`shared_buffers`, `work_mem`, `effective_cache_size`) is highly server-specific and not covered in depth here — use [PGTune](https:\u002F\u002Fpgtune.leopard.in.ua\u002F) as a starting baseline.\n- The built-in Odoo profiler only captures **Python + SQL** traces; JavaScript rendering performance requires browser DevTools.\n- **Odoo.sh** managed hosting restricts direct PostgreSQL and `odoo.conf` access — some tuning options are unavailable.\n- Does not cover **Redis-based session store** or **Celery task queue** optimizations, which are advanced patterns for very high-traffic instances.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,189,2042,"2026-05-16 13:32:16",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"2c26484a-1d5f-4a46-a647-db9f541ea7a4","1.0.0","odoo-performance-tuner.zip",2512,"uploads\u002Fskills\u002F2924d8c1-c17a-44e7-9241-a87aba639f23\u002Fodoo-performance-tuner.zip","424917cd12a4143c67893a130d5e40b4e20d9169005be91df6c6a4e9a23b6473","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4872}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]