Managing Database Logic with Yii Active Record
Learn how to use Yii's Active Record to replace manual SQL with object-oriented CRUD, automate model creation with Gii, and solve the N+1 query problem.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to use Yii's Active Record to replace manual SQL with object-oriented CRUD, automate model creation with Gii, and solve the N+1 query problem.
Stop the N+1 query problem in Django. Learn exactly when to use select_related for SQL joins and prefetch_related for Python-side lookups to optimize ORM performance.
Avoid N+1 queries in SQLAlchemy by choosing selectinload for collections and joinedload for scalar relationships, then verify with echo=True.
Use CakePHP ORM contain to eager load associations and avoid separate queries inside loops, with verification steps for CakePHP 4.x and 5.x.
Configure Hibernate @BatchSize and hibernate.default_batch_fetch_size to load lazy associations in groups instead of one query per row.
Stop database performance degradation in Hibernate by replacing Offset-based pagination with Keyset pagination (the Seek Method) for large datasets.
Unbounded find('all') queries with associations can crash CakePHP index actions. Build one ORM query, contain only what the template needs, and enforce limits with paginate().
Learn how SQLAlchemy's joinedload replaces N+1 queries with a single JOIN for many-to-one and one-to-one relations, when to use it, and what to watch out for.
Learn why cursor‑based pagination outperforms Hibernate’s OFFSET‑based approach for large datasets and how to implement it safely.