Django - Deepstash

🏮

Django

7 STASHED IDEAS

Speed up common queries
  • Add indexes on fields you frequently filter/sort on.
  • Analyze query plans generated by common queries and identify bottlenecks.
  • Rewrite queries to return smaller results sets when possible.
  • Re-model data in a way that allows indexes to work more efficiently.
  • As a last resort, use raw SQL when you can't generate an efficient query through the ORM.

STASHED IN:

2

📖 Two Scoops of Django

STASHED IN:

0 Comments

Model recommendations
  • Alternate/complex constructors for model instances should be implemented as manager methods. (e.g. User.objects.create_user)
  • Custom, complex or often-used queries on the entire table should be implemented as QuerySet or manager methods.
  • Table-level queries should be implemented as a QuerySet method when they need to be chained, and as a manager method otherwise.
  • Complex fetching of related objects from a model instance should be implemented as a model method.

STASHED IN:

3

STASHED IN:

0 Comments