Created
May 31, 2025 10:54
-
-
Save docsallover/fd0669128b3c43b2492ac4f9d00104d5 to your computer and use it in GitHub Desktop.
Db indexing in django using the indexes option within your model's Meta class for more complex or multi-column indexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order(models.Model): | |
customer_email = models.EmailField() | |
order_date = models.DateTimeField(auto_now_add=True) | |
class Meta: | |
indexes = [ | |
models.Index(fields=['customer_email', 'order_date']), # Composite index | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment