I am using a CharField
in django to store a primary key. I have defined this as:
id = models.CharField(
max_length=64, default=create_id, primary_key=True, null=False, editable=False
)
This results in my table having the following two indexes:
CREATE UNIQUE INDEX api_participant_pkey ON public.api_participant USING btree (id)
CREATE INDEX api_participant_id_cb12634b_like ON public.api_participant USING btree (id varchar_pattern_ops)
The text in the id is meaningless, I am always going to query that field through an exact match, never using LIKE
.
Is there an easy way to remove the _like
index?
I've seen How to remove index varchar_pattern_ops in a django (1.8) migration? on how to remove the index when it is a field being indexed, but I am not sure how to do this for a primary or foreign key.
I'm using postgresql and Django==2.2.13 and this is a live database I cannot just recreate.