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

  1. Make a ForeignKey. Don't specify a value for db_index (django sets it to True by default)
  2. Make a migration for the foreignkey. This creates an index:
CREATE INDEX "a_c_b_id_5a026661" ON "a_c" ("b_id");
  1. Explicitly set db_index=False and create another migration
  2. 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

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top