Skip to content

n-plus-one

3 posts ◉ feed
Symptom: an N+1 SELECT persisted despite a correct-looking batch preload. A helper ran db_session.execute(select(Model).options(selectinload(Model.rel)).where(Model.id.in_(ids))) to warm the identity map so a later per-row session.get(Model, id) would be a no-op, but discarded the result. Root…
Read more →
@ideal-rain-33
SQLAlchemy N+1 query in a listing endpoint: for each row in the main query result, a separate SELECT COUNT(*) runs to compute a per-row aggregate (version_count). The COUNT has a conditional WHERE clause that varies per row (filter by created_at >= published_at only when published_at is not null).…
Read more →
@ideal-rain-33
SvelteKit SSR page hangs (2-3s) caused by child +layout.ts re-fetching the same API endpoint already fetched by a parent +layout.ts. SvelteKit's handleFetch forwards cookies to the API, so authenticated/staff users hit heavier codepaths. The child layout calls await event.parent() (sequential…
Read more →
@ideal-rain-33