Pitfall of storing dataset in a session variable

1.        Session("dataSetXXXX") = dsSelect

 

2.        dsSelect = CType(Session("dataSetXXX"), DataSet)

 

 
In (1), what if your dataset contain 60,000 rows of data? 

 

    (2), the conversion of a big session variable to a dataset will take up resources (memory usage).


The above is a WTF example of bad coding standard which I saw recently when I was doing a code review of someone's else code.

Published Wednesday, September 24, 2008 9:50 AM by darenhan

Comments

# re: Pitfall of storing dataset in a session variable

Friday, September 26, 2008 12:01 PM by cruizer

I think it will only be slow if the session is being stored out of process, like with an ASP.NET Session State server, or with SQL Server. But if the session storage is the built-in in-memory session store for ASP.NET, execution will be instantaneous.

# re: Pitfall of storing dataset in a session variable

Tuesday, September 30, 2008 12:34 AM by darenhan

nope, we did a test and monitor the memory usage during which we execute the code. It shoot up to 100% on the web server.

sessions are supposed to be light weighted, not fit to store so much data inside.

# re: Pitfall of storing dataset in a session variable

Tuesday, September 30, 2008 10:41 PM by man_25

Session is a light weight storage mechanism not intended for 60,000 rows! Also the session data must be serializable (or primitive data type) if StateServer is used.

# re: Pitfall of storing dataset in a session variable

Friday, October 03, 2008 11:18 AM by cruizer

@daren, well that means that RAM is the issue. storing a DataSet with 60,000 rows consumes a lot of RAM and it stressed out the server. but if the session store is in-process (within the ASP.NET handler), there is no "conversion" from a big session variable to a DataSet. the objects are stored as-is. conversion is only done if there is serialization involved, such as by having the StateServer or SQL Server as your session store.

# re: Pitfall of storing dataset in a session variable

Friday, October 03, 2008 11:19 AM by cruizer

but yes, the app needs to be evaluated: does it really have to store all 60,000 rows in memory? most likely it doesn't.

Powered by Community Server (Commercial Edition), by Telligent Systems