﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22125	Unnecessary creation of index for ManyToManyField	tbhtan3@…	nobody	"Suppose I have the following model:
class Food(models.Model):
  restaurants = models.ManyToManyField(Restaurant)

The following table is created:

CREATE TABLE ""main_food_restaurants"" (
    ""id"" integer NOT NULL PRIMARY KEY,
    ""food_id"" integer NOT NULL,
    ""restaurant_id"" integer NOT NULL,
    UNIQUE (""food_id"", ""restaurant_id"")
)

and the indexes:

CREATE INDEX ""main_food_restaurants_0899c464"" ON ""main_food_restaurants"" (""food_id"");
CREATE INDEX ""main_food_restaurants_be4c8f84"" ON ""main_food_restaurants"" (""restaurant_id"");

Notice that  the single index on food_id is not needed due to the unique index (food_id, restaurant_id)
"	Cleanup/optimization	new	Database layer (models, ORM)	1.6	Normal				Unreviewed	0	0	0	0	1	0
