Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Designs safe Django and PostgreSQL indexes from measured query plans, covering composite, partial, GIN, BRIN and concurrent migrations.
91% 100%+9 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 20 of 22 without it.
3 of 3 safety checks passed
Not used yet
from django.db import models
class Order(models.Model):
account = models.ForeignKey("accounts.Account", on_delete=models.CASCADE)
status = models.CharField(max_length=32)
created_at = models.DateTimeField()
metadata = models.JSONField(default=dict)
class Meta:
indexes = [
models.Index(
fields=["account", "status", "-created_at"],
name="order_acct_status_created_idx",
),
models.Index(
fields=["created_at"],
condition=models.Q(status="open"),
name="order_open_created_idx",
),
models.Index(
fields=["account"],
include=["status", "created_at"],
name="order_account_cover_idx",
),
]
Use condition for partial indexes and include for covering indexes where the backend supports them. PostgreSQL requires immutable functions in index expressions and partial-index conditions.
from django.contrib.postgres.indexes import BrinIndex, GinIndex
from django.db import models
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.