Skip to content
Back to skills

Doctrine Batch Processing

ASecurity

Process large datasets with Doctrine (ORM 3 toIterable, flush+clear, bulk DQL) and memory management

  • 221 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added August 31, 2026
developmentgoshellbashsqlrailsperformance

Security analysis

A100/100

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

Scanned October 6, 2026

npx -y skills add dev-toolings/superpowers-symfony --skill doctrine-batch-processing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Doctrine Batch Processing?

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

Security grade badge for Doctrine Batch Processing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dev-toolings-doctrine-batch-processing/badge)](https://www.skillsdirectory.com/skills/dev-toolings-doctrine-batch-processing)

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: doctrine-batch-processing
description: Process large datasets with Doctrine (ORM 3 toIterable, flush+clear, bulk DQL) and memory management
capabilities: [read, search, edit, shell]
tags: [doctrine, performance]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
---

# Doctrine Batch Processing (Symfony)

## Use when
- Processing more rows than fit in memory: imports, exports, backfills.
- A command or worker runs out of memory iterating over entities.
- Updating or deleting many rows at once.
- Inserting large volumes through Doctrine or DBAL.

## Default workflow
1. Measure the dataset size and the memory budget of the process.
2. Stream reads with `toIterable()`, or paginate by id (`id > :lastId`) for very large tables.
3. Flush and `clear()` every N items, and re-fetch anything needed after a clear.
4. Use DQL `UPDATE`/`DELETE` or DBAL for bulk writes that need no hydration.
5. Log memory usage and progress, and make the run resumable.

## Guardrails
- Never `findAll()` on a table that grows.
- Entities loaded before a `clear()` are detached: do not modify or persist them.
- Bulk DQL and DBAL skip lifecycle events and listeners. Check what relies on them.
- On ORM 3, `Query#iterate()` and `setSQLLogger()` are gone: use `toIterable()` and a logging middleware.
- Paginate by id rather than by offset: offsets get slower and skip rows when data moves.

## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.

## Output contract
- A batch loop with an explicit batch size and clear points.
- The choice between ORM, DQL bulk and DBAL for each write, with the reason.
- Memory measurements before and after on a realistic volume.

## References
- `reference.md`

Files in this skill

  • SKILL.md1.1 KB
  • reference.md7.5 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.

Comments

Loading comments…