Skip to content
Back to skills

Frappe Performance

ASecurity

Frappe/ERPNext speed. Use when code is slow, for heavy queries, N+1 loops, caching, indexes, background jobs with frappe.enqueue, or bulk data work.

  • 10 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 24, 2026
ai-agentspythonsqlapiperformance

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add irfanzahoor/frappe_core_skills --skill frappe-performance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Frappe Performance?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Frappe Performance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/irfanzahoor-frappe-performance/badge)](https://www.skillsdirectory.com/skills/irfanzahoor-frappe-performance)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: frappe-performance
description: Frappe/ERPNext speed. Use when code is slow, for heavy queries, N+1 loops, caching, indexes, background jobs with frappe.enqueue, or bulk data work.
---

# Performance

## Queries

- Fetch only needed fields: `frappe.get_all("Item", filters=..., fields=["name", "item_group"])`.
- Never `frappe.get_doc` inside a loop to read values. Bulk fetch and map:

```python
# ❌ N+1
for row in self.items:
    group = frappe.db.get_value("Item", row.item_code, "item_group")

# ✅ one query
item_codes = [row.item_code for row in self.items]
groups = dict(frappe.get_all("Item", filters={"name": ("in", item_codes)},
                             fields=["name", "item_group"], as_list=True))
for row in self.items:
    group = groups.get(row.item_code)
```

- Aggregates in SQL/QB (`Sum`, `Count`), not by loading rows into Python.
- Add `search_index` on fields used in frequent filters (in the DocType field settings).
- Use `pluck="name"` for simple lists of names.
- `frappe.db.get_value` with `cache=True` / `frappe.get_cached_value` / `frappe.get_cached_doc`
  for rarely-changing masters (Company, settings).

## Writes

- Bulk updates: `frappe.db.set_value` with filters, or QB `update`, not doc-by-doc save — but only
  when skipping controller validation is acceptable.
- Don't `frappe.db.commit()` inside requests; the framework commits. Allowed in long background
  jobs / patches processing batches.

## Background jobs

```python
frappe.enqueue(
    "my_app.my_module.jobs.recalculate_balances",
    queue="long",
    timeout=1500,
    company=company,
    enqueue_after_commit=True,
)
```

- Anything slow (bulk processing, emails in bulk, external API calls, report generation) → enqueue.
- Notify the user on completion with `frappe.publish_realtime` or a notification.
- Jobs must handle their own errors with `frappe.log_error`.

## Client

- Avoid `frappe.call` in `refresh` for data that rarely changes; load once in `onload` or use
  `frm.doc.__onload` set by the controller's `onload()` method.
- Debounce calls triggered by typing.

Files in this skill

  • SKILL.md2 KB
  • references/query-index-guide.md2.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.