Opened 7 years ago
Last modified 7 years ago
#28339 new Cleanup/optimization
Setting db_index=False on a ForeignKey doesn't actually remove the index — at Initial Version
Reported by: | Craig de Stigter | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
- Make a
ForeignKey
. Don't specify a value fordb_index
(django sets it toTrue
by default) - Make a migration for the foreignkey. This creates an index:
CREATE INDEX "a_c_b_id_5a026661" ON "a_c" ("b_id");
- Explicitly set
db_index=False
and create another migration - Check
sqlmigrate
for the new migration. Index is never actually removed:
BEGIN; -- -- Alter field b on c -- COMMIT;
One note: This is with postgres settings. I'm not sure if it's db-specific
Note:
See TracTickets
for help on using tickets.