Skip to content

Consider adding AlterIndexOperation to Migrations #20692

Description

@lajones

Per discussion with @bricelam when reviewing PR #20634

Currently a FILLFACTOR change causes a DROP and CREATE of the index on which the fillfactor is defined. But in SQL Server (2008 onwards) it's possible to just do:

ALTER INDEX REBUILD WITH FILLFACTOR nn

We should consider the relative performance of ALTER INDEX versus DROP and CREATE and perhaps add an AlterIndexOperation class to migrations.

Note: several other operations are allowed on ALTER INDEX. We would need to consider which of them to support.

Activity

  1. bricelam commented on Apr 22, 2020

    @bricelam
    Contributor

    On SQL Server, it looks like this syntax avoids the need to rebuild referencing foreign keys. However, this is minimized by the fact that any foreign keys created by EF will be referencing unique constraints and not unique indexes.

  2. roji commented on Apr 23, 2020

    @roji
    Member

    FWIW PG also allows various index modifications. I think there's more than enough reason to do this.

  3. added this to the Backlog milestone on Apr 24, 2020
  4. self-assigned this
    on Oct 6, 2021
  5. roji commented on Oct 17, 2022

    @roji
    Member

    Another thought on this: when the migrations SQL generator sees an AlterIndexOperation with a facet that cannot be altered, it can automatically drop and recreate the index. This would save users the trouble of having to do it themselves.

  6. removed their assignment
    on Jul 8, 2023
  7. roji commented on Oct 27, 2023

    @roji
    Member

    FWIW I just ran into this again in a PG-related thing (npgsql/efcore.pg#2899).

  8. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions