DashboardsentryNever query DB in serialize() for bulk …

Never query DB in serialize() for bulk endpoints — always use get_attrs()

Category: preference
Confidence: 1.00
ID: 019fb3b9-f4b4-735b-8b56-3128a0834336
Project ID: 702228c8-56bc-4694-8d5a-174ac2f29105
Cross-project: No
Recalled in other projects: 0
Source session: 0rWXqG93IDSIFMxki
Created: 2026-07-30 15:52:16
Updated: 2026-07-30 15:52:16

Content

Directive (Burak Yigit Kaya, 2026-07-30): for bulk serializer endpoints, NEVER query the database in serialize(). Use get_attrs() for batched prefetch instead. serialize() runs once per item, so a DB query there becomes an N+1 explosion. get_attrs() is called once per request and lets you batch-load related data. Trap: this looks like premature optimization for small N — the right framing is bulk endpoints scale, and the per-item DB query is structurally wrong, not just slow.

Move to: