Django and DRF
336 subscribers
98 photos
39 files
161 links
Purpose is sharing, spreading knowledge which is most related to the Django and Django Rest Framework(DRF)

You can find in here my
- Articles
- Projects with source codes
- Videos
and another useful stuffs
Download Telegram
https://medium.com/@pesarakex/how-i-reduced-a-3gb-django-table-query-from-12s-to-200ms-with-just-3-indexes-eec82e99cec9

Django model:

class Record(models.Model):
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
status = models.CharField(max_length=50)
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
indexes = [
models.Index(fields=['user', 'status'], name='idx_record_user_status'),
models.Index(fields=['-created_at'], name='idx_record_created_at'),
models.Index(fields=['user', 'status', '-created_at'], name='idx_record_user_status_created'),
]
Lesson?
You don’t need 17 microservices when you can write clean Django apps with clear domain boundaries. Monoliths scale just fine if you don’t treat them like spaghetti.

Link to the article
👍1