c# - Why is an index created more than one time in SQL via Entity Framework -


i have written service, imports every night more 960.000 rows sql database. data used other operations few hours later. application .net application, entity framework on it. import being made entityframework bulkextensions.

after 3-4 imports, receive timeoutexceptions.

some experts company reviewed whole code. code-side seems ok.

now have taken sql server. running sql server 2014 professional.

after running query:

select object_name(i.object_id) tablename,         i.name indexname,         indexstats.avg_fragmentation_in_percent         sys.dm_db_index_physical_stats(db_id(),                                             null,                                             null,                                            null,                                             'detailed') indexstats         inner join sys.indexes on i.object_id = indexstats.object_id         indexstats.avg_fragmentation_in_percent > 30         , i.index_id = indexstats.index_id 

i got following result: result of query

now question is, why index2 being created more 1 time? have expected 1 row table 2 1 index (ix_index2).

this doesn't answer question directly i'm afraid.

regardless of above query, may want consider dropping or disabling index prior data load , rebuilding / enabling after data load. probably more efficient otherwise index updated data being imported.

this article provides simple code show how if you're not doing so:

to disable in index, issue alter index command.

alter index ix_indexname on schema.tablename disable; go 

if want re-enable index, need rebuild – there no alter index…enable command. rebuild works this:

alter index ix_indexname on schema.tablename rebuild; go 

to drop clustered or nonclustered index, issue drop index command.

drop index indexname on schema.tablename; go 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -