Opened 8 years ago
Last modified 8 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 |
Pull Requests: | How to create a pull request | ||
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
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Note:
See TracTickets
for help on using tickets.