entity framework - ef-core - bool index vs historical table -
i´m using aspnet-core, ef-core sql server. have 'order' entity. i'm expecting orders table large , frequent query active orders customer (active orders tiny fraction of whole table) optimize speed of query can decide 2 approaches:
1) don't know if possible haven't done before, thinking creating boolean column named 'isactive' , make index when querying active orders faster.
2) when order becomes not active, move order table, i.e historicalorders, keeping orders table small.
which of 2 have better results?, or none of solution , third approach suggested?
before think new table historicalorders
,just create column name isactive
, test data.you don't need make index column.b'cos indexes eat storage , slows down writes , updates.so must careful when create index.when query data shown below.on below query data selection (or filter) done on sql srever side (iqueryable
).so fast.
note : use asnotracking()
too.it boost perfromnace too.
var activeorders =_context.set<orders>().where(o => o.isactive == true).asnotracking() .tolist();
reference : asnotracking()
Comments
Post a Comment