#28077 closed New feature (fixed)
Allow specifying custom operator classes for PostgreSQL indexes
Reported by: | IzyJeepee | Owned by: | Ian Foote |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Normal | Keywords: | postgres, gin, operator, class |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello,
I want use the GinIndex method to create a gin index with the django's migration. But while the migration, I have this errror :
django.db.utils.ProgrammingError : data type character varying has no default operator class for access method "gin" HINT : You must specify an operator class ofr the index or define a default operator class for the data type.
This error may be resolved by enabling the btree_gin extension.
It is possible to pass the operator class during the index's creation ? For example :
class Meta: indexes = [ GinIndex(fields=['my_field'], name='my_index_gin', operator_class='my_operator') ]
Thanks
Change History (9)
comment:2 by , 8 years ago
follow-up: 4 comment:3 by , 8 years ago
Summary: | GinIndex() and operator class → Allow specifying an operator class for GinIndex() |
---|---|
Triage Stage: | Unreviewed → Accepted |
I don't have much expertise here about the use cases and how this might interact with #27437. Tentatively accepting for further investigation.
comment:4 by , 8 years ago
https://github.com/mjtamlyn/django/blob/5ae3c70b405486fb81bcbf33b209f1301fade246/django/db/backends/postgresql/schema.py#L31-L35 so the issue of this may already being worked on?
comment:5 by , 7 years ago
I've a use case where I am always doing __contains
query on JSONField
. So, I would prefer GIN index to be created using jsonb_path_ops
operator class rather than the default jsonb_ops
.
comment:6 by , 7 years ago
Component: | contrib.postgres → Database layer (models, ORM) |
---|---|
Has patch: | set |
Owner: | set to |
Summary: | Allow specifying an operator class for GinIndex() → Allow specifying custom operator classes for PostgreSQL indexes |
comment:7 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:8 by , 7 years ago
I've noticed that in the postgis schema editor, we have custom index creation code for single-field indexes for geodetic
fields. For example, we set the GIST_GEOMETRY_OPS_ND
operator class for fields with dimension higher than two.
It would probably be good to refactor to allow this custom code to integrate with the operator class support I've added, but I'm not familiar enough with postgis to be confident making a change without guidance.
#27437 looks like it's overlapping a little bit.