Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create explicit index objects for every index #700

Closed
ajcvickers opened this issue Sep 25, 2014 · 7 comments
Closed

Create explicit index objects for every index #700

ajcvickers opened this issue Sep 25, 2014 · 7 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-unknown
Milestone

Comments

@ajcvickers
Copy link
Member

Currently some indexes are inferred from keys by Migrations when using relational models. Per design meeting notes every index should be created explicitly in the model.

@rowanmiller rowanmiller added this to the 1.0.0-beta1 milestone Sep 29, 2014
@divega divega modified the milestones: 1.0.0-beta1, 1.0.0-rc1 Oct 20, 2014
@rowanmiller rowanmiller modified the milestones: 7.0.0-rc1, 7.0.0 Nov 25, 2014
@bricelam
Copy link
Contributor

We need to be careful to avoid creating duplicate indexes in the database. Most databases create an implicit index for PRIMARY KEY and UNIQUE constraints. If you then explicitly create an INDEX on the same columns, a new, duplicate index will be maintained by the database.

@bricelam
Copy link
Contributor

Marking for re-triage; this should probably be pri0. Without this, Migrations won't create unique indexes for 0..1:0..1 relationships effectively making them 0..1:* in the database.

Here are the main things that would change in Metadata:

Before After
Key.IsClustered Key.Index.IsClustered
ForeignKey.IsUnique ForeignKey.Index.IsUnique

Migrations would then promote the indices' configuration to the CREATE..PRIMARY KEY AND CREATE..UNIQUE clauses and skip creating indexes associated with keys.

For foreign keys, everything should "just work" in Migrations since there is typically no implicit index on FOREIGN KEY constraints.

@bricelam bricelam removed this from the 7.0.0 milestone Aug 18, 2015
@rowanmiller rowanmiller added pri0 and removed pri1 labels Aug 21, 2015
@rowanmiller rowanmiller added this to the 7.0.0 milestone Aug 21, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0-rc1, 7.0.0 Sep 17, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0, 7.0.0-rc1 Oct 14, 2015
@bricelam
Copy link
Contributor

Yes, the tests will need to be updated.

@smitpatel
Copy link
Contributor

blocked by #3648
GraphUpdate tests are failing.

@smitpatel
Copy link
Contributor

Decision:
We’ll create indices by convention for each foreign key. The user owns this index and is free to update or delete it. The index will not be used when reasoning about foreign keys or relationships.
We won’t create indices for keys. Keys will continue to mirror some of the metadata that can also be defined on index (e.g. SqlServerIsClustered) in both the core metadata (as annotations) and the Fluent API. If an index is created over the same columns as a key, both a primary key/unique constraint and an index will be created in the database (i.e. we won’t collapse them in Migrations).
-Brice

Implemented in #3764

@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-unknown
Projects
None yet
Development

No branches or pull requests

6 participants