# 25_backend_issues

ormquerydjango

Issues to be vary about

# N + 1 Problem

The N+1 Queries Problem is a perennial database performance issue. It affects many ORM’s and custom SQL code, and Django’s ORM is not immune either.

Abusing the databse with large number of smaller queries insteead of one or two large queries.

Eg: Books and Authors DB Schema

To get a list of 10 books with author information N+1 queries are made to DB

# Django query optimization get results in a single query

For ForeignKey, you can use selected_related()

Comment.objects.select_related('video').all()

Bools.objects.select_related('author').prefetch_related('books')
  • django debugger can show you how many queries were made to db

# References

# SQLite in S3 bucket?

Low concurrency read+writes as it locks the entire DB file while querying

I am looking for work opportunities. If you like my work and feels it was helpful kindly support me by


Buy Me A Coffee