Skip to content

Duplicate database indexes #18188

Answered by jeremystretch
acscampos asked this question in Q&A
Discussion options

You must be logged in to vote

Looking at the first instance, there are indeed two similar indexes:

"vpn_tunnelt_termina_c1f04b_idx" btree (termination_type_id, termination_id)
"vpn_tunneltermination_termination" UNIQUE CONSTRAINT, btree (termination_type_id, termination_id)

I believe this is because we explicitly define an index for the generic foreign key (GFK) relation termination, which Django does not do automatically. Separately, we also declare a uniqueness constraint for this pair of fields, to ensure an object cannot have more than one termination. Hence the duplicate indexes. It should be safe to remove the former index.

I haven't dug into the others but I suspect they all result from similar situations, and…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by acscampos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants