c# - Stored Procedure and Entity Framework Insert Query - Performance -
i have simple insert
statement, table inserting data has millions of rows. problem insert
statement being executed every 2 -3 seconds.
my cpu usage reaches 80%+ usage, due insert statement.
i need ask that, if write stored procedure insert, increase performance?
stored procedures stored in sql there performance improvement because sql knows procedures has , can optimize execution. furthermore entity framework presents kind of wrapper around database functionality. means little bulky, because classes , methods/properties. try it, bring improvement.
that said, don't think problem because of ef vs stored procedures dilemma. due millions of records in table. when performing insert
, database checks kinds of things, such foreign keys, constraints, triggers triggered etc. other things, influence performance , database related, such size of transaction log etc.
i try 2 things:
i create identical table identical triggers, indexes, primary keys, foreign keys, ... except leave empty. try if current application still takes forever when
insert
. if works fast, database related.if previous point wouldn't work, assume, there problem code, create stored procedure , try again. if work ok, change code use stored procedures , consult db admin particular situation.
Comments
Post a Comment