CodingASP.NET SQL Session cost

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Ally  
 To:  ALL
37623.1 
A question that I have so far failed to find answer to if anyone (hi, Rendle) has the answer:

We store our site sessions in a database, so that it's accessible across all the web servers. I'm trying to increase performance a little by reducing the number of (normal, non-session) DB calls we make by storing more data in the session.

Now, I don't know how ASP.NET internally queries the session data. For instance, when I do:

C# code:
Session["blahblah"]


does it fire off a query? Or does it load up all the session data in one big gulp before the page load, and store it in memory? I'm assuming it's the latter, but can't find any confirmation on this. If it's the former, then my optimisations are hardly worth doing.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  Ally     
37623.2 In reply to 37623.1 
Can you monitor the database [table] to see the queries being run?

doohicky

0/0
 Reply   Quote More 

 From:  Ally  
 To:  Matt     
37623.3 In reply to 37623.2 
Unfortunately not- my local dev environment uses in-memory sessions- it doesn't use DB-based sessions until it's on the live server. In any case, I've looked at the session tables before and they're just a deeply confusing mess... I'm sure they're also very efficient, but they confuse the hell out of me.
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Ally     
37623.4 In reply to 37623.1 

The SQL session provider loads values as you reference them. But once it's loaded during a request, it is cached in memory for the remainder of that request process.

 

Microsoft are generally quite good at making their things optimal for stuff like this.

Happy now?

0/0
 Reply   Quote More 

 From:  Ally  
 To:  THERE IS NO GOD BUT (RENDLE)     
37623.5 In reply to 37623.4 

Sorry, never replied to say thanks for this.

 

Thanks for this!

0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Ally     
37623.6 In reply to 37623.5 
Welcome.

Happy now?

0/0
 Reply   Quote More 

Reply to All    
 

1–6

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats