开发者

What is the efficient way to store multiple values in Sql Server Session database?

I have 10 - 12 variables on my aspx page which needs to be stored in SQL server Session database(load balancer environment).

What is the the efficient way of storing and retrievi开发者_C百科ng them

  1. group every thing in a class and and store in session ( i am thinking this will reduce the number of database calls)

  2. Storing each variable in session ( I am thinking this will make database calls for every session object i stored)

Can any of you please suggest me the efficient way to do it?


It probably doesn't matter in terms of performance, so use whatever produces the cleanest code.

Each separate session item does not require a separate database call. The entire session is loaded from the db at the start of the request; the entire** session is then written back to the db at the end of the request (assuming that the request isn't using a read-only session).

There will be minor performance differences due to how native types are serialised compared to custom objects (size of the serialised data and/or CPU cost to serialise). These differences will usually be minor compared to the cost of the round-trips to the database.


** I must admit that I can't actually remember whether the entire session is written back to the db or only those items that have been added/modified during the current request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜