Skip to main content

Create JSON indexes concurrently

Project description

Create JSON Indexes concurrently

The functionality provided by this Django App is similar to the indexes, except that it provides an option to create indexes concurrently.

Currently, only Postgres JSON Indexes are supported.


Install the latest version using pip:

pip install django_indices

Add django_indices to INSTALLED_APPS in the django settings file:


Run the migrations:

python migrate django_indices

Add the indices you want to the Meta class of the required Model. Then run the migrate_indices management command to add / remove the indices:

python migrate_indices


from django.db import models
from django.db.models import Q
from django.contrib.postgres.fields import JSONField

from django_indices import JSONIndex

class Inventory(models.Model):
    data = JSONField()

    class Meta:
        indices = [
            # Creates an index on data->'product_type'
            # Indexes are created concurrently by default, which doesn't lock
            # the table.
                field=["data", "product_type"],

            # Creates a unique index on data->'product'->>'id'
            # concurrently=False ensures that the index creation will execute
            # in a transaction. So the index is either created successfully,
            # or fails cleanly. This will lock the table though.
                field=["data", "product", "id"],

            # Creates a partial compound index on
            # (data->'product'->>'brand', data->'product'->>'size')
            # WHERE data->>'product_type' = 'shoe' OR data->>'product_type' = 'crocs'
                field=(["data", "product", "brand"], ["data", "product", "size"]),
                where=(Q(data__product_type="shoe") | Q(data__product_type="crocs"),


Project details

Download files

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

Files for django-indices, version 0.0.4.post2
Filename, size File type Python version Upload date Hashes
Filename, size django_indices-0.0.4.post2-py3-none-any.whl (8.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-indices-0.0.4.post2.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page