c# - How to prevent LocalDB from detaching MDF file after some idle time? -
i'm building .net 4.5 (winforms) application uses localdb work local mdf file, using connection string:
data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\db\databasefile.mdf;integrated security=true;multipleactiveresultsets=true
when run application, first sql query takes time execute - nothing drastic, 2 or 3 seconds. after that, next sql queries executed instantly. assume seconds during first execution needed attach mdf file local sql server service. right?
i noticed, however, if 10 minutes (or so) pass since sql query last performed, next sql query again take 2-3 seconds more execute. assume after idle time, mdf gets detached, , when new sql command called, re-attaches once again.
i'm wondering, there way override behavior?
i know create timer
, performs simple query every few minutes, there better, cleaner solution?
i more suspect data / index no longer in memory.
you run fast query select 'a' know if connect time.
as forcing table / index stay in memory.
advise let .net , sql own memory management.
2-3 seconds not much.
@ query plan - maybe can make faster (even not in memory).
Comments
Post a Comment