dizballanze/django-eraserhead

💂🏻 Django package that provides hints to optimize database usage by deferring unused fields (and more)

django
django-models
django-orm
monkey-patching

Django Eraserhead

image

image

image

image

Provide hints to optimize database usage by deferring unused fields

image

WARNING use this package only in dev environment!

Documentation

Requirements -----------

  • Django 1.9+
  • Python 2.7, 3.4+

Quickstart

Install Django Eraserhead:

pip install django-eraserhead

Add it to your `INSTALLED_APPS`:

INSTALLED_APPS = (
    ...
    'eraserhead.apps.EraserheadConfig',
    ...
)

ERASERHEAD_ENABLED = True
ERASERHEAD_TRACEBACK_BASE_PATH = BASE_DIR

Settings:

  • [ERASERHEAD_ENABLED]{.title-ref} - enable/disable Django Eraserhead
  • [ERASERHEAD_TRACEBACK_BASE_PATH]{.title-ref} - set base path to filter tracebacks. Set to [None]{.title-ref} to display full traceback.

Features

image

Django Eraserhead monitors:

  • querysets/models fields usage (used and unused fields) with considering deferred fields
  • count of instances created for each queryset
  • corresponding model of each queryset
  • traceback for each queryset to easily find corresponding code
  • calculate memory consumption of unused fields

Based on fields usage Django Eraserhead suggests optimizations for each queryset.

TODO

  • decorator and/or context processor for partial stats collecting
  • detect deferred fields loading
  • auto deferring fields based on usage
  • display deferred fields

Running Tests

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

Stars
196
0.00% more than last month
Forks
3
Open Issues
3