Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Managing State - db vs. session vs. XML 1

Status
Not open for further replies.

XgrinderX

Programmer
Mar 27, 2001
225
0
0
US
Hello!

I am in the process of rewriting an application that currently uses both session vars and a database to track certain user and application specific data.

My question is: which is the most efficient for managing this data? Currently the application sets session variables for a lot of the user based info and it goes to the database to get a lot of application specific info. It hits the database asking for this info on pretty much every single page and I can't help but wonder if there is not a better way to do it. However I don't want to throw ALL the data into session vars as I am afraid that would put too much stress on the server memory.

Would it be more efficient to write an XML file out when the user logs in and access that XML file to retrieve the needed data on each page? Or is that less efficient than going to the database? I've tried looking around for comparisons on the methods and have not been very successful.

Thanks,

-Greg
 
It depends on the number of users you have on your site and the number of variables you are going to track.

also, you could look into using application variables.
 
Searching a database should be much faster than searching an xml file.
 
Not to mention stale data from the session variables. It seems to me that if it needs to hit the database, let it. I'd rather have a trip to the db than stale data in my session. You're already going to the server for the page, what's a side trip to the database while you're at it?
 
Thanks for your replies. Sheco hit the main thing I was trying to determine - is going to the database on every page more efficient than going to an XML file.

As for using application variables, this is not possible since we are using one codebase for several different applications each with different setups. When a user logs in for a certain application, we grab all the setup info from the database.

So even stale data is not an issue with XML as we would just write a new XML file for that user whenever they login. Disk space is not a problem, but we were obviously worried about memory issues if we tried to do session variables.

So if the consensus is that the round trip to the database on every page call is more efficient than parsing through XML on every page call, then we will keep the data calls. If this is the case, can someone point me to an article or white paper that verifies this claim? I've been trying to find one and all I can find is info about the various ways to maintain state, but nothing I have found does any comparison of efficiency with each method.

Thanks everyone!
 
I don't have a white paper but I'm sure there are sources on google.

Just think about it, a proper DBMS is totally dedicated to storing and retrieving data. The big commercial products like Oracle/SQLServer/DB2 is a billion dollar industry and they compete on speed and scalability.

I'm sure you can find a fast third party XML parser for sale but the little free one that comes with the server probably won't be anywhere near the same level of optimization so the only hope for better speed will be if network latency slows your database transactions to a crawl. This is especially true once you get up around 50K unique files in a single directory this can really slow the filesystem before you even get to the XML parser. On the other hand 50K rows is no problemo for a database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top