Opened 2 years ago

Closed 18 months ago

Last modified 18 months ago

#18046 closed Cleanup/optimization (fixed)

document index created for a ForeignKey

Reported by: jbauer@… Owned by: raulcd
Component: Documentation Version: 1.4
Severity: Normal Keywords: ForeignKey db_index
Cc: raulcumplido@…, timograham@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


It would be helpful if the Model field docs mentioned that Django automatically creates an index for ForeignKey columns.

The docs could also mention how to disable this behavior (db_index=False) and why the user may want to do this:

  • FK created for consistency, not joins
  • alternative special indexes (partial, multiple column, etc) will be created instead

Relevant links:

Attachments (1)

18046.diff (711 bytes) - added by timo 18 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 2 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/optimization

comment:2 Changed 23 months ago by raulcd

  • Cc raulcumplido@… added
  • Owner changed from nobody to raulcd

Changed 18 months ago by timo

comment:3 Changed 18 months ago by timo

  • Cc timograham@… added
  • Has patch set

comment:4 Changed 18 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In db598dd8a053fe17c3308f89cd8f40676e2c479e:

Fixed #18046 - Documented than an index is created by default for ForeignKeys; thanks jbauer for the suggestion.

comment:5 Changed 18 months ago by Tim Graham <timograham@…>

In fd90a906333b569340e5507fec3f3a4d4c1d0f47:

[1.4.X] Fixed #18046 - Documented that an index is created by default for ForeignKeys; thanks jbauer for the suggestion.

Backport of db598dd8a0 from master

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.