跳到正文
Skillpedia
部署与云(DevOps)48k · #5346

odoo-performance-tuner

它能做什么

这个智能体帮你找出导致 Odoo 变慢的问题并加以修复。它会分析缓慢的数据库查询、内存设置,以及其他导致卡顿的原因。

适用场景

  • ✓Odoo 页面加载很久时。
  • ✓系统出现内存错误或超时时。
  • ✓想了解哪些数据库查询运行得很慢时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/odoo-performance-tuner/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/odoo-performance-tuner/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的 Odoo 特别慢,你能帮我找找原因吗?”

每周 5 个新技能,1 分钟读完。

工作原理

你描述变慢的情况,并分享报错信息或配置等信息。智能体会进行分析,然后建议需要做的调整来提升性能。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Odoo Performance Tuner

Overview

This 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.

When to Use This Skill

  • Odoo is slow in production (slow page loads, timeouts).
  • Getting MemoryError or Worker timeout errors in logs.
  • Diagnosing a slow database query using Odoo's profiler.
  • Tuning odoo.conf for a specific server spec.

How It Works

  1. Activate: Mention @odoo-performance-tuner and describe your performance issue.
  2. Diagnose: Share relevant log lines or config and receive a root cause analysis.
  3. Fix: Get exact configuration changes with explanations.

Examples

Example 1: Recommended Worker Configuration

# odoo.conf — tuned for a 4-core, 8GB RAM server

workers = 9                   # (CPU_cores × 2) + 1 — never set to 0 in production
max_cron_threads = 2          # background cron jobs; keep ≤ 2 to preserve user-facing capacity
limit_memory_soft = 1610612736  # 1.5 GB — worker is recycled gracefully after this
limit_memory_hard = 2147483648  # 2.0 GB — worker is killed immediately; prevents OOM crashes
limit_time_cpu = 600          # max CPU seconds per request
limit_time_real = 1200        # max wall-clock seconds per request
limit_request = 8192          # max requests before worker recycles (prevents memory leaks)

Example 2: Find Slow Queries with PostgreSQL

-- Step 1: Enable pg_stat_statements extension (run once as postgres superuser)
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

-- Step 2: Also add to postgresql.conf and reload:
-- shared_preload_libraries = 'pg_stat_statements'
-- log_min_duration_statement = 1000   -- log queries taking > 1 second

-- Step 3: Find the top 10 slowest average queries
SELECT
    LEFT(query, 100) AS query_snippet,
    round(mean_exec_time::numeric, 2) AS avg_ms,
    calls,
    round(total_exec_time::numeric, 2) AS total_ms
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;

-- Step 4: Check for missing indexes causing full table scans
SELECT schemaname, tablename, attname, n_distinct, correlation
FROM pg_stats
WHERE tablename = 'sale_order_line'
  AND correlation < 0.5   -- low correlation = poor index efficiency
ORDER BY n_distinct DESC;

Example 3: Use Odoo's Built-In Profiler

Prerequisites: Run Odoo with ?debug=1 in the URL to enable debug mode.

Menu: Settings → Technical → Profiling

Steps:
  1. Click "Enable Profiling" — set a duration (e.g., 60 seconds)
  2. Navigate to and reproduce the slow action
  3. Return to Settings → Technical → Profiling → View Results

What to look for:
  - Total SQL queries > 100 on a single page  → N+1 query problem
  - Single queries taking > 100ms             → missing DB index
  - Same query repeated many times            → missing cache, use @ormcache
  - Python time high but SQL low             → compute field inefficiency

Best Practices

  • ✅ Do: Use mapped(), filtered(), and sorted() on in-memory recordsets — they don't trigger additional SQL.
  • ✅ Do: Add PostgreSQL B-tree indexes on columns frequently used in domain filters (partner_id, state, date_order).
  • ✅ Do: Enable Odoo's HTTP caching for static assets and put a CDN (Cloudflare, AWS CloudFront) in front of the website.
  • ✅ Do: Use @tools.ormcache decorator on methods pulled repeatedly with the same arguments.
  • ❌ Don't: Set workers = 0 in production — single-threaded mode serializes all requests and blocks all users on any slow operation.
  • ❌ Don't: Ignore limit_memory_soft — workers exceeding it are recycled between requests; without the limit they grow unbounded and crash.
  • ❌ Don't: Directly manipulate prefetch_ids on recordsets — rely on Odoo's automatic batch prefetching, which activates by default.

Limitations

  • PostgreSQL tuning (shared_buffers, work_mem, effective_cache_size) is highly server-specific and not covered in depth here — use PGTune as a starting baseline.
  • The built-in Odoo profiler only captures Python + SQL traces; JavaScript rendering performance requires browser DevTools.
  • Odoo.sh managed hosting restricts direct PostgreSQL and odoo.conf access — some tuning options are unavailable.

…

常见问题

Odoo 中的 workers 是什么?

Workers 是在 Odoo 中执行任务的进程。调整它们的数量和内存上限对性能至关重要。

智能体如何找到慢查询?

它可以借助 Odoo 和 PostgreSQL 的工具,找出哪些数据库命令的耗时超出预期。

如果我的 Odoo 托管在 Odoo.sh 上,还能使用吗?

有些设置,比如直接访问 PostgreSQL 或修改 odoo.conf 配置,在 Odoo.sh 上可能无法进行。

详情

作者的原始描述

Expert guide for diagnosing and fixing Odoo performance issues: slow queries, worker configuration, memory limits, PostgreSQL tuning, and profiling tools.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5346
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能