I'm using Microsoft's Entity Framework. It automatically creates indices for every foreign key, but in many cases, I can see from the index stats that these are never used for reading – they are only ever updated (which doesn't surprise me as I doubt I am ever actually doing a join on many of them). My gut feeling is that I should remove these indexes as they are just slowing down updates (albeit probably not that significantly) and taking up space. I like to try to keep things clean and lean. Is there a good reason to keep them?
Sql-server – Remove some auto created indices from Entity Framework
entity-frameworkindexsql server
Related Question
- Sql-server – Rolling Back Stored Procedures in Entity Framework
- SQL Server and Entity Framework – Self Referencing Tables
- SQL Server – Is Trace Considered Harmful in Production?
- Entity Framework – SaveChanges Fails Due to a Trigger
- Entity Framework Database Coupling – Best Practices
- SQL Server 2016 – One-to-Many Relationships and Index Fragmentation
Best Answer
Foreign keys should be indexed as a best practice. If you're not using them now, you can disable them or drop them, but you may want to use them later. The impact on performance is negligible in most cases if you keep them.
I'd leave them as is.