18 January 2010

Does ASPState need full recovery?

I prefer to use SQL to keep session data in my ASP.NET applications. In order to do so, you need to create the state database (usually called ASPState) in SQL Server. Have you noticed that its transaction log will keep growing unless you take regular backups?

I don't know about you, but I don't really need backups of my session database (the main application database is a different matter, of course). The data that I store in session is very transient. If it ever crashes, I'm not going to try to recover the data. I'm happy to recreate the (empty) database and let the users come back to the application with a brand new session.

So, what's the solution? Well, I set the ASPState database to use the simple recovery model. Once that's done, the transaction log won't be a problem any more. Additionally, if you already have a large transaction log, you might want to shrink it after you change the recovery model.

No comments: