Skip to main content

django-mysql-fix

This project contains optimizations (hacks) for MySQL for Django ORM.

It’s based on Django 1.7 (master branch). It was started on PyCon 2014 Development Sprint.

We are going to test possible regressions that might appear in real projects. This backend will pass all Django tests, but we still have to test it in real projects.

How does it affect me?

There are two very simple ways to cacth INNER JOIN bug:

  • Once you specify field from foreign table in list_display in your Django Admin model;

  • Once you try to sort (order) by field from foreign table.

In these cases even if you limit query by 1 it will join whole tables, order them and only after that it will slice it to limit. Thus if you have i.e. 400k records in two tables it would take 3+ seconds to get small slice. STRAIGHT_JOIN forces MySQL work as we expect: order -> slice -> join.

How to use

Specify django-mysql-fix backend in your DATABASES setting in Django settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django_mysql_fix.backends.mysql',
        ...
    },
}

Compatibility

Tested with Django master branch and Django 1.6.0+.

It doesn’t work with Django <= 1.5.x.

Fixed issues

For now there is only one optimization there.

  • MySQL INNER JOIN with order fails to optimize query that ends up with seconds to get result, but STRAIGHT_JOIN instead of INNER JOIN solves the issue and we can get result in 0.001 instead of 3+ seconds. https://code.djangoproject.com/ticket/22438

Metadata

Release files for django-mysql-fix 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mysql-fix 0.1.6
File Size Uploaded
django-mysql-fix-0.1.6.tar.gz 4.0 kB Details

Release files / django-mysql-fix-0.1.6.tar.gz

Download URL django-mysql-fix-0.1.6.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ec5a2a41054ecf8023360be8dc9f9aa7f9ea8d9df4e286bd206d1f4be6c7f88e
BLAKE2b-256 checksum
How to use checksums
5fa7b94279ebd2a70b7ec9fefc320c000b9f5143bad2d2f6cc47e614096966fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.6 This release

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page