Using XML to Store Session Data - 08 May 2000
To eliminate session variables in Active Server Pages (ASP) applications, you can store all session variables in an XML string.
May 7, 2000
This week, I taught some sessions at VB and ASP Connections in Phoenix,Arizona, and learned a lot from those who shared their experiences withme and other attendees. One session was about how to eliminate sessionvariables in Active Server Pages (ASP) applications. The well-attendedsession generated a lot of questions and discussion.
We talked at length about how to use XML to store session data. Youcould, for example, store all session variables in an XML string, thendrop that string into a field in the session row. When an applicationneeded to retrieve the data, it could then use the Microsoft XML parseror a custom-built parser to extract the named fields and values. Thatsolution appears very workable, at least on a conceptual level.
Then someone asked whether you should store the XML string in a charor a varchar field and the performance impact of each. Storing thestring in a char field instead of a varchar field should give youfaster performance because when SQL Server performs an update, it hasto expand a varchar field.
Several other people at the session who were familiar with theperformance effects of using char vs. varchar confirmed my advice. Oneperson said his team was charged with deploying an application thatused SQL Server. After deploying the application, the team found thatit performed terribly. Upon inspecting the database, team membersdiscovered that all the fields were varchar. They changed the fields tochar, and the application now performs fine.
This is the second person in the past week who has told me about adatabase problem related to poor configuration. Whether you're workingwith SQL Server, XML, or another technology, success is in the details.And the best way to learn the nitty-gritty design, development, andimplementation details, is to get in there and just do it. If somethingdoesn't work or perform the way you want, do some testing and try adifferent approach. Learn by doing. That’s how experts get to beexperts.
About the Author
You May Also Like