efcore icon indicating copy to clipboard operation
efcore copied to clipboard

SQL Server Index Fill Factor

Open bender-ristone opened this issue 6 years ago • 7 comments

How to specify the index option, fe FILLFACTOR?

CREATE NONCLUSTERED INDEX [IX_Name] ON [dbo].[Demo]
(
	[Name] ASC
)
WITH (FILLFACTOR = 80) ON [PRIMARY]
modelBuilder.Entity<Demo>(entity =>
{
      entity.HasKey(e => e.Gid);
      entity.HasIndex(e => e.Name).HasName("IX_Name");
});               
                

bender-ristone avatar Dec 03 '19 12:12 bender-ristone

@bender-ristone I will discuss with the team, but I don't think there is currently a way to express this in EF Core. You may need to edit the generated migration and write the SQL above explicitly.

ajcvickers avatar Dec 04 '19 19:12 ajcvickers

@ajcvickers

I started to do something about it, could you look and tell me if that would be the way before sending PR?

https://github.com/ralmsdeveloper/EntityFrameworkCore/commit/1fbcf5c871589b46fef96858cd2491cffca48676

FYI:

  • Support is only for the SQL Server provider.

/cc: @bricelam

ralmsdeveloper avatar Apr 13 '20 00:04 ralmsdeveloper

@ralmsdeveloper Looks reasonable. @roji @bricelam Is fill-factor SQL Server-specific?

ajcvickers avatar Apr 14 '20 20:04 ajcvickers

@ajcvickers, first thanks for looking, I will still improve some things, this is a draft.

Is fill-factor SQL Server-specific?

Is not SQL Server specific, PostgreSQL also supports Fill Factor. As other banks databases do not have support, I thought of working with annotation, otherwise we will need to create another property in DatabaseIndex.

ralmsdeveloper avatar Apr 14 '20 21:04 ralmsdeveloper

Yeah, the SQL Server and PostgreSQL CREATE INDEX syntax even seems to be identical for fill factor (when has that ever happened??).

MySQL (InnoDB) also has this concept, although at the database level only (didn't find anything for Sqlite).

I'm not sure it makes sense to introduce this into relational, as for now we're seeing support in 2 database out of 4...

roji avatar Apr 14 '20 22:04 roji

Removing from the backlog to discuss whether this should be provider-specific or not.

ajcvickers avatar Apr 15 '20 17:04 ajcvickers

@ralmsdeveloper We discussed and agreed that this is fine to be in the SQL Server provider. We'll follow up on the PR. Thanks!

ajcvickers avatar Apr 17 '20 20:04 ajcvickers