Re: Business Objects and Session Variables

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Cowboy \(Gregory A. Beamer\) (NoSpamMgbworld_at_comcast.netNoSpamM)
Date: 02/03/04


Date: Tue, 3 Feb 2004 08:07:23 -0600

The DB hit is not normally too bad on most modern networks. Since there is a
certain amount of pooling of connections, you are not taking the most major
part of the hit each time. Is it a much greater hit than caching? Certainly.
But, it is not critical in many applications. The question is where you wish
to cache. You can use Session to easily cache without building anything. Or,
you can set up your own caching mechanism.

-- 
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
**********************************************************************
Think Outside the Box!
**********************************************************************
"Tim Stall" <anonymous@discussions.microsoft.com> wrote in message
news:35E966A2-9B9B-4F55-AC13-8881871B7486@microsoft.com...
> You could also store it in the Cache (if it is a commonly used object)  or
ViewState (for the scope of a single page).
>
> Storing everything in session may give you huge performance hits, and make
testing very difficult (it's generally harder to test Session objects
because they could "interfere" with the session on other pages, as opposed
to viewstate). Also, as the scope of Session could be for multiple pages,
and you're looking for a scope that covers just the postback of a single
page (I assume), session would give you more than you needed.
>
> You're right that generally, storing the PK and rehitting the DB will be a
*major* performance hit.
>
> Tim
>
>
>      ----- Tu-Thach wrote: -----
>
>      Dave,
>      I usually store information that are needed frequently in session
that saves me from querying the database.  Just as you mentioned, there will
be tradeoffs for either approach that you go with.  The point to use use it
appropriately so that you minimize the potential problems.
>
>      Tu-Thach
>
>           ----- Dave Wurtz wrote: -----
>
>           All,
>
>           I'm new to ASP development and I have a basic design question:
>
>           Is it ok to store business objects to session variables or is
there a better
>           way to keep object information?
>
>           For example, if a user logs onto the website, a user object is
created that
>           stores their full name, email address, street address, phone,
etc.  This
>           object also has methods to do 'other' things such as
validations, counters,
>           etc.  When the user logs in, the object is instantiated.  Is it
ok to keep
>           this object for the life of the session?  If some items are
always needed
>           (for example maybe the full name is on the header of every
page), it is very
>           convenient just to call a property off of the user object.
>
>           I've also seen some examples where the primary key of the object
is stored
>           in the session variable, and the object is rebuilt all of the
time.  Which
>           way is better?
>
>           Storing the user object for the life of the session is
definitely more
>           convenient for the programmer, but is it going to kill my
performance?  On
>           the other hand, recreating the user object each time would
potentially have
>           to requery the database to retrieve information - is this going
to kill my
>           performance?
>
>           Any help on this would be very much appreciated!
>
>           Thanks.
>
>           Dave Wurtz
>           Advanced Software Designs
>
>
>


Relevant Pages

  • Re: Incomlete object?
    ... have you tried commenting code and uncommenting until you hit the error. ... | I have a few classes, and I keep objects of those in session. ... | index.php -> class Page, starts session, in constructor inits database ... | point I get an error that it is incomplete (DB is stored in session as ...
    (alt.php)
  • Re: Are Test matches getting too predictable?
    ... in the morning session on day-1, or "score as many as possible in 20 ... try to hit out for 20 overs, run the singles for the next 20, and then ... hit out again in the last 10. ... result but, in my view, a bigger gain in more competent cricket. ...
    (rec.sport.cricket)
  • Re: this is what u get from pap mp
    ... A RAG-AND-BONE man accused of criminal intimidation said yesterday that he was made to wait almost four hours to see his Member of Parliament at a Meet-the-People session. ... When he got to see the MP, Jalan Besar GRC's Denise Phua, he ranted at her that the $200 he got from a government agency in financial aid was not enough, which spurred one of her grassroots helpers to shout at him just as he was leaving. ... 'How can you not hit her? ... He then decided to call the Prime Minister's Office to tell the Prime Minister - the 'boss of all MPs' - why people were treating their MP like that. ...
    (soc.culture.singapore)
  • Re: Sql session state
    ... The DB will be hit with every page. ... > I have a few question regarding sql session state. ... > database hit until session expires or is there a database hit every ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Accuracy decline afield affirms need for more accuracy!
    ... I haven't yet hunted with a scope. ... I find that I hit about the same and group the same with or ... lifesize deer targets to hopefully engrain these conditions better into ... I need to work on my field senses ...
    (rec.hunting)