Ban 1+N in Django

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Scout Monitoring - Free Django app performance insights with Scout Monitoring
Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.
www.scoutapm.com
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • django-zen-queries

    Explicit control over database query execution in Django applications

    See also django-zen-queries https://github.com/dabapps/django-zen-queries , which can make it impossible for changes to a template to trigger queries.

  • Scout Monitoring

    Free Django app performance insights with Scout Monitoring. Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.

    Scout Monitoring logo
  • haxl

    A Haskell library that simplifies access to remote data, such as databases or web-based services.

    +1. The JS event loop auto-monad-izing Promises into Haxl [1]-esqe trees of implicitly-batched loads has been a big win for us building on JavaScript/TypeScript.

    If I had to move to another language, I'd really want to find a "powered by the event loop / dataloader" framework, i.e. Vert.x for Java.

    Also, per dataloader, a shameless plug for our ORM that has dataloader de-N+1-ing built natively into all object graph traversals:

    https://joist-orm.io/docs/goals/avoiding-n-plus-1s

    [1]: https://github.com/facebook/Haxl

  • funcy

    A fancy and practical functional tools

    On an unrelated note, Python folks should check out OP's library funcy [1]: "A collection of fancy functional tools focused on practicality. Inspired by clojure, underscore and my own abstractions."

    Thanks for the library Suor!

    [1] https://github.com/Suor/funcy

  • bullet

    help to kill N+1 queries and unused eager loading

    Rails has Bullet[0] to help identify and warn you against N+1

    Does Django have anything active? Quick search revealed nplusone[1] but its been dead since 2018.

    [0] https://github.com/flyerhzm/bullet

    [1] https://github.com/jmcarp/nplusone

  • nplusone

    Auto-detecting the n+1 queries problem in Python

    Rails has Bullet[0] to help identify and warn you against N+1

    Does Django have anything active? Quick search revealed nplusone[1] but its been dead since 2018.

    [0] https://github.com/flyerhzm/bullet

    [1] https://github.com/jmcarp/nplusone

  • django-cacheops

    A slick ORM cache with automatic granular event-driven invalidation.

    Here is an example of such thing https://github.com/Suor/django-cacheops/blob/8b3a79de29b2545...

  • django-orm-plus

    I was working on a library to do this which I never got around to fully finishing but the idea is there: https://github.com/lime-green/django-orm-plus I think all I had left was polishing the auto add logic and testing with a real project

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • pellet

    Pellet helps improve your Django app performance by discovering N+1 queries. (by har777)

    Self plug: Checkout https://github.com/har777/pellet to easily find and fix django N+1 issues.

    I usually add it to existing integration tests so that they raise exceptions on N+1. If test coverage is low then I would suggest sending the N+1 metrics to something like datadog. That way your users using the product will reveal all the N+1 issues on your monitoring solution.

  • django-auto-prefetching

    Automatic prefetching for Django

    Shameless plug - I ran into this while developing REST interfaces with Django and built django-auto-prefetching: https://github.com/GeeWee/django-auto-prefetching

    It essentially travels your DRF serializer tree and builds an auto-prefetched query automatically without you needing to do any work.

    Back when I still worked actively on it, I wanted to monkey-patch models to track whether or not n+1 was happening, and if it was, automatically do pre-fetching, so instead of an n+1 problem you'd end up with just a "3-4 queries when it could've been 1" problem - which is much more palatable. Never got around to that part though.

  • django-seal

    Django application providing queryset sealing capability.

    If I understand it correctly, that's what [django-seal](https://github.com/charettes/django-seal) does.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • How to profile an asynchronous FastAPI server

    1 project | /r/Python | 9 Aug 2023
  • How to expand to full traceback

    1 project | /r/vscode | 11 Jul 2023
  • Graphical Python Profiler

    4 projects | news.ycombinator.com | 5 Jul 2023
  • Easiest way to add write-through cache for auth_user queries?

    3 projects | /r/django | 16 May 2023
  • DRF Performance (How bad is this code?)

    1 project | /r/django | 10 Apr 2023