skillfed

nplusone

Detecting the n+1 queries problem in Python

nplusone v1.0.0 600.5K downloads/30d#5,821 on PyPI1,068
License unclear Copyright 2016 Joshua Carp Abandoned released

What it is and what it does

nplusone is an ORM profiling tool that detects the n+1 queries problem—a common performance pitfall where an application issues many redundant database queries instead of using efficient joins or batch loading. It integrates with Django, Flask-SQLAlchemy, Peewee, and generic WSGI applications to monitor query patterns during development.

The tool logs warnings when it detects lazy-loaded relationships that could be eagerly loaded for better performance, and also warns about eagerly loaded data that is never accessed in the current request. It supports both framework middleware integration (Django, Flask) and a generic profiler context manager for non-HTTP code. Configuration options allow raising exceptions on detected problems to fail automated tests, and whitelisting specific models or fields to suppress false positives.

Use it for:

  • Identify n+1 query patterns during Django development before they reach production
  • Profile Flask-SQLAlchemy applications to find inefficient relationship loading
  • Detect unused eager loads that waste database resources in request handlers
  • Enforce query efficiency in automated tests by raising exceptions on n+1 detection
  • Diagnose slow ORM performance by pinpointing the exact code lines causing lazy loads

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Detects n+1 query problems in Python ORMs (Django, SQLAlchemy, Peewee) by monitoring lazy and eager loading patterns and logging warnings when inefficient queries are emitted.

No—not for new projects. The package is abandoned (last release May 2018, no commits since November 2022) and its license treatment is unclear. While it solves a real problem and has low install friction, modern Django and SQLAlchemy versions may not be fully supported, and there is no active maintenance. Consider modern alternatives like django-silk, django-debug-toolbar, or SQLAlchemy's own query analysis tools for current development.

Install

nplusone on PyPI

pip

pip install nplusone

uv

uv add nplusone

poetry

poetry add nplusone

Installing nplusone

Before you install

Low install friction with only two runtime dependencies (six and blinker). However, the project is abandoned—last release was in May 2018 and no commits since November 2022. Not suitable for production use; development-only tool.

License in practice

License treatment is unclear; raw license text indicates copyright by Joshua Carp but no SPDX identifier is present. Verify licensing terms before use in proprietary or commercial contexts.

Quickstart

pip install nplusone

# Django: add to INSTALLED_APPS and MIDDLEWARE
INSTALLED_APPS = (..., 'nplusone.ext.django')
MIDDLEWARE = ('nplusone.ext.django.NPlusOneMiddleware', ...)

# Flask-SQLAlchemy
from nplusone.ext.flask_sqlalchemy import NPlusOne
app = Flask(__name__)
NPlusOne(app)

Development-only tool; do not deploy to production. Requires Django >= 1.8 or Flask-SQLAlchemy for framework integrations.

Verify before relying

  • Whether the unclear license permits commercial or proprietary use
  • Compatibility with modern Django and SQLAlchemy versions released after 2018
  • Whether the tool functions correctly with current ORM lazy/eager loading patterns

Package facts

License Copyright 2016 Joshua Carp (unclear)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — six, blinker
Maintenance abandoned — 3,007 days since the last release
Last repo commit
First released
Downloads 600,458/month — #5,821 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: nplusone-1.0.0-py2.py3-none-any.whl

Tags

n+1 query detectionORM performance profilinglazy loading detectorDjango query optimizationSQLAlchemy profilerdatabase query monitoringeager load detection
orm-profilingdevelopment-onlyabandoned

More Quality Assurance packages