जैसे-जैसे एक Django application बढ़ती है, database आमतौर पर पहला और सबसे महत्वपूर्ण bottleneck होता है। इसे scale करने में query optimization, indexing, connection management, read replicas, caching, और अंततः architectural changes शामिल हैं — database को संबोधित करना अधिकांश Django apps के लिए सबसे high-leverage scaling काम है।
1. पहले queries को optimize करें (सबसे बड़े, सबसे सस्ते wins)
Book.objects.select_related().prefetch_related()
Article.objects.only(, )
Article.objects.values()
django.db.models Count, Sum
Author.objects.annotate(book_count=Count())
