Opened 17 years ago

Closed 16 years ago

#5680 closed (fixed)

DatabaseFeatures.autoindexes_primary_key is unnecessary

Reported by: Nis Jørgensen <nis@…> Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: db-be-api
Cc: Erin Kelly Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The db backend setting autoindexes_primary_key is unnecessary - since all backends do this.

Note that the changes necessary collide with my patch for #5671

2 patches attached:

  • one that fixes this issue, against trunk
  • one that combines this patch with the one for 5671.

Attachments (5)

autoindex.diff (3.3 KB ) - added by Nis Jørgensen <nis@…> 17 years ago.
Fixes just this issue
autoindex_combined.diff (6.7 KB ) - added by Nis Jørgensen <nis@…> 17 years ago.
Combined with fix for 5671
autoindex.2.diff (3.8 KB ) - added by Erin Kelly 17 years ago.
Updated patch after [7375]
models-mysql-duplicated-index-and-foreign-constraints.py (434 bytes ) - added by Peter Melvyn <peter.melvyn@…> 16 years ago.
example demonstrating duplicated index and foreign key constraints on MySQL
r7811-mysql-duplicated-index-and-foreign-constraints.py (564 bytes ) - added by Peter Melvyn <peter.melvyn@…> 16 years ago.
Generated SQL showing duplicated index and foreign key constraints on MySQL

Download all attachments as: .zip

Change History (15)

by Nis Jørgensen <nis@…>, 17 years ago

Attachment: autoindex.diff added

Fixes just this issue

by Nis Jørgensen <nis@…>, 17 years ago

Attachment: autoindex_combined.diff added

Combined with fix for 5671

comment:1 by Nis Jørgensen <nis@…>, 17 years ago

I forgot to mention the discussion thread about the issue.

comment:2 by Jacob, 17 years ago

Triage Stage: UnreviewedAccepted

by Erin Kelly, 17 years ago

Attachment: autoindex.2.diff added

Updated patch after [7375]

comment:3 by Erin Kelly, 17 years ago

Cc: Erin Kelly added

I just added another reference to the autoindexes_primary_keys feature, so I've updated this patch to reflect that.

comment:4 by Ramiro Morales, 16 years ago

See also #3030

comment:5 by Ramiro Morales, 16 years ago

Keywords: db-be-api added

comment:6 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [7790]) Make sure we only create the minimum number of table indexes for MySQL.

This patch simplifies a bunch of code for all backends and removes some
duplicate index creation for MySQL, in particular (versions 4.x and later).
Patch from Nis Jørgensen.

Fixed #5671, #5680, #7170, #7186.

comment:7 by Peter Melvyn <peter.melvyn@…>, 16 years ago

Resolution: fixed
Status: closedreopened

This patch (with removed autoindexes_primary_keys feature) does not treat duplicated indexes and foreign key constraints on MySQL, whereas setting its value to True has solved it.

comment:8 by Malcolm Tredinnick, 16 years ago

Please provide an example of how to duplicate the problem you are talking about. I tested the changes in [7790] fairly carefully with MySQL + InnoDB and couldn't create any duplicate indexes. So what case did I miss? Without more information I cannot hope to fix things.

by Peter Melvyn <peter.melvyn@…>, 16 years ago

example demonstrating duplicated index and foreign key constraints on MySQL

by Peter Melvyn <peter.melvyn@…>, 16 years ago

Generated SQL showing duplicated index and foreign key constraints on MySQL

comment:9 by Peter Melvyn <peter.melvyn@…>, 16 years ago

After uploading example, I reviewed MySQL tables again and I notice that there is now redundant index actually. Instead, if index is not supplied explicitly, MySQL creates inherent one.
Perhaps I confused it with foreign key duplications in ticket #7186 seeing CONSTRAINTS and CREATE INDEX commands together.
Sorry for the noice...

comment:10 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: reopenedclosed

I had just finished typing in a bunch of output to show exactly that. In both MySQL 4 and MySQL 5 it doesn't create the index implicitly if one is specified. There's no bug here.

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