Skip to main content

Discover possible N+1 queries in your code base

Project description

django_nplusone

Discover possible N+1 queries in Django ORM at runtime

The objective of this library is to help you discover any N+1s in your code at development time. Enable logging of warnings by following instructions shown in Usage section. Run your Django app as usual and you will see warning logs of any possible N+1s if found.

Installation

Install the package from PyPI using pip as following

pip install django_nplusone

Usage

Once package is installed, you can register the package in your settings.py as:

import nplusone

if DEBUG:
    nplusone.show_nplusones()

This should start logging possible N+1s warnings using your logger configuration. The library uses standard python logging module and uses logger by the name of nplusone.

Test

You can test the N+1 warning logging by putting some code as shown below somewhere in your application code that you know will get executed. Say you have a model User with a foreign key field org to Organization model.

user = User.objects.all()[0]
print(user.org)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_nplusone-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

django_nplusone-0.0.3-py2-none-any.whl (4.4 kB view details)

Uploaded Python 2

File details

Details for the file django_nplusone-0.0.3.tar.gz.

File metadata

  • Download URL: django_nplusone-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/2.7.5

File hashes

Hashes for django_nplusone-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4a3c333783ac345c322a97938fc238081606336475f821d79b2e4681d98e4500
MD5 dbb5845fe9372d823118cecdffc2a25f
BLAKE2b-256 f33014495185b12e748fd3d3b37395ef8b9316b1a6490d420d1da0134b9ac463

See more details on using hashes here.

File details

Details for the file django_nplusone-0.0.3-py2-none-any.whl.

File metadata

  • Download URL: django_nplusone-0.0.3-py2-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/2.7.5

File hashes

Hashes for django_nplusone-0.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 02837169486c9c65bfc6c63081d4a79589fe7fd2517ccd6dce40f416aa65870b
MD5 7a25c35d9f6ed0f358a832977f57fcb7
BLAKE2b-256 2b3c51013fcf6879ed705eb2e094d71163f4ddc71cc006e8c811e199f7d1eb54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page