Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've noticed a strange behaviour of SQL Server 2008 r2 express:

usually my query execution time is ~650ms, but if I open Management Studio and run any simple query (for example SELECT * FROM Something), the execution time becomes ~40ms. If I close management studio this value returns to normal ~650ms

And no matter where the query was executed: from Management Studio or my application (it uses ADO.Net)

ARITHABORT setting has no effect

Why is this happening?

share|improve this question

migrated from Mar 6 '12 at 13:40

This question came from our site for professional and enthusiast programmers.

up vote 22 down vote accepted

The database you are querying probably has "auto close" enabled.

The connection from SSMS stops the database closing. When you close SSMS, the database closes. A subsequent call requires it to be opened.

Auto close is the default for SQL Server Express and is not a good idea:

share|improve this answer
+1 learned something new... again... – Lieven Keersmaekers Mar 6 '12 at 7:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.