RE: ViewState vs. Database



Hi MMC,

Thanks for your quick response.

For the bottleneck issue, I suggest you try the following things:

1. ASP.NET's output trace can print out the time each event finished or any
output statement's time, and you can write out some custom statement in
each event and lookup the time slot in the trace.

2. Visual studio 2005/2008 provide performance profiling tools that can
help us profile application(include desktop and web apps)'s performance.
such as which part takes most time or which part is called most frequently:

#Analyzing Application Performance
http://msdn.microsoft.com/en-us/library/z9z62c29(VS.80).aspx

#Visual Studio Profiler Team Blog
http://blogs.msdn.com/profiler/

this is helpful to detect potential bottlenecks in many cases.

For your further question "As a general rule - which is better? And why?",
here is my opinion for your reference:

1. If database server is powerful enough to support frequent query/update
processing or such operations are not quite frequent, I'll always do the
query instead of caching the data. Since that can save webserver memory.

2. If data is quite large and operations are so frequent that may impact
database server, I'll first consider caching data at server-side (such as
in memory cache) rather than use page's viewstate. The reason is as below:

** given anytime, for an application, user experience is the most
important, large page size is certainly big problem for client user
experience.

** also, large page content also impact server memory since such large
data(in form field) is post back to server and write down to client in
every request, so means ASP.NET runtime need to load it into memory
everytime processing page request.

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.






--------------------
From: =?Utf-8?B?TUNN?= <MCM@xxxxxxxxxxxxxxxx>
References: <DB321895-A729-496F-B9B5-423029159B7B@xxxxxxxxxxxxx>
<lzALYqj4IHA.4056@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: ViewState vs. Database
Date: Wed, 9 Jul 2008 23:15:00 -0700
40.244.149
X-Tomcat-NG: microsoft.public.dotnet.general

From your description, you're wondering tradeoff between storeing
database
records in ASP.NET page's viewstate and query them in every request,
correct?

Yes.

Based on my understanding, if you're using Databound control(such as
Gridview, DataGrid)

Not using datagrid. Using custom display controls. I can choose to
enable/disable viewstate.

3. If the bottleneck is not at the web application and backend database
server(performing data accessing operations such as query data), I
recommend you query the data from database in every request where you
need
to display the data. But if the data is large and really static or
unchangable, you can consider using Application Cache to cache them.

That is my point. I don't know where my bottleneck is yet. I'm looking for
a
"best practice". Something that works in most scenarios. I can choose to
enable view state and only hit the database once - then reuse the data for
multiple postbacks - this will obviously create a larger html response to
the
client. Or I can choose to keep the page size smaller, but hit my database
on
each postback - this will be more taxing on the server of course. As a
general rule - which is better? And why?

-------------------

#Using the ASP.NET Application Cache to Make Your Applications Scream
http://www.developer.com/net/net/article.php/1477771

#ASP.NET Caching Overview
http://msdn.microsoft.com/en-us/library/ms178597.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.



--------------------
Thread-Topic: ViewState vs. Database
thread-index: AcjiL9LHoL7fpWJYTuakWT7C3nnrKw==
X-WBNR-Posting-Host: 207.46.19.168
From: =?Utf-8?B?TUNN?= <MCM@xxxxxxxxxxxxxxxx>
Subject: ViewState vs. Database
Date: Wed, 9 Jul 2008 18:54:00 -0700


I'm sure the answer to my question varies depending on the situation,
but
I
am looking for a general "best practice".

If I have an asp.net application and I load certain data from a
database,
should I use ViewState to store and reload the data, or should I load
the
data from the database on each postback?

Assume for the sake of this question that I only care about
performance, I
don't care about ease of programming.






.



Relevant Pages

  • Re: SBS 2003 R2 with domain and TS logins
    ... The solution could be moving the database app to its own server, or adding additional resources to the current server. ... But admin level logins to your SBS box are not a solution, and wouldn't allow you 5 sessions regardless. ... So far so good, then they have a mapped shared directory on the server that they run a database application from by a shortcut on the desktop, now here is the problem, everything slows down once they access the database and it is then hard for them to work. ... Is it a network bottleneck, a CPU bottleneck, a disk access bottleneck, perhaps an odd database issue itself ...
    (microsoft.public.windows.server.sbs)
  • Re: SBS 2003 R2 with domain and TS logins
    ... Their system consists of a hp server with sbs2003r2 sp2 std and 5 workstations. ... So far so good, then they have a mapped shared directory on the server that they run a database application from by a shortcut on the desktop, now here is the problem, everything slows down once they access the database and it is then hard for them to work. ... You can add another server to the domain that acts as a terminal server, but the SBS system itself cannot be one. ... Is it a network bottleneck, a CPU bottleneck, a disk access bottleneck, perhaps an odd database issue itself ...
    (microsoft.public.windows.server.sbs)
  • Re: SBS 2003 R2 with domain and TS logins
    ... To set up a TS, you'd simply buy/build a server, install the version of Windows Server you're going to use, and join it to the domain. ... But admin level logins to your SBS box are not a solution, and wouldn't allow you 5 sessions regardless. ... So far so good, then they have a mapped shared directory on the server that they run a database application from by a shortcut on the desktop, now here is the problem, everything slows down once they access the database and it is then hard for them to work. ... Is it a network bottleneck, a CPU bottleneck, a disk access bottleneck, perhaps an odd database issue itself ...
    (microsoft.public.windows.server.sbs)
  • RE: calling a function/query
    ... Is the database here also the access mdb database file you mentioned in ... displayed in the vs 2005 server explorer, ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.academic)
  • Create SharePoint Portal failed.
    ... One mentioned ensuring that SQL Server uses a case ... 13:55:40 Service database server is 'USDC-JOHRIV'. ... Update dbo.propertylist set DisplayName = N'Last name' ...
    (microsoft.public.sharepoint.portalserver)

Loading