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.
Installation
Install the latest version using pip:
pip install django_indices
Add django_indices to INSTALLED_APPS in the django settings file:
INSTALLED_APPS = (
...,
"django_indices",
)
Run the migrations:
python manage.py 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 manage.py migrate_indices
Example
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.
JSONIndex(
field=["data", "product_type"],
name="idx_inventory_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.
JSONIndex(
field=["data", "product", "id"],
name="idx_inventory_product_id",
unique=True,
concurrently=False,
),
# Creates a partial compound index on
# (data->'product'->>'brand', data->'product'->>'size')
# WHERE data->>'product_type' = 'shoe' OR data->>'product_type' = 'crocs'
JSONIndex(
field=(["data", "product", "brand"], ["data", "product", "size"]),
name="idx_inventory_footwear_brand_size",
where=(Q(data__product_type="shoe") | Q(data__product_type="crocs"),
),
]
Metadata
Release files for django-indices 0.0.4.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-indices-0.0.4.post1.tar.gz | 4.8 kB | Without provenance | Details for django-indices-0.0.4.post1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_indices-0.0.4.post1-py3-none-any.whl | Python 3 | none | any | Details for django_indices-0.0.4.post1-py3-none-any.whl |
Total release size: 13.4 kB
Release files / django-indices-0.0.4.post1.tar.gz
| Download URL | django-indices-0.0.4.post1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d8773d1e1ba915d5372c72c5b9957d4659f2b71dc8d24fa69c8db654c977da5
|
|
BLAKE2b-256 checksum How to use checksums |
2ac6b6281c6f1243c2f5ff57a3b20a0f7f42d915ec82b625e516e03c63db44ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0
|
Release files / django_indices-0.0.4.post1-py3-none-any.whl
| Download URL | django_indices-0.0.4.post1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d8f995623288b483dc29b0c65ef7f4998b3cbb5a5b0b29d9e83aebca95e2ff6
|
|
BLAKE2b-256 checksum How to use checksums |
8c7784f81d7789191cb80da5742ad39e7f787e22bc10a7f9b455279941f92b53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0
|
Security for django-indices 0.0.4.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.