Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ASP.net 2.0 issue with long queriesASP.net 2.0 issue with long queries
Previous
 
Next
New Post
6/4/2008 8:46 AM
 

Hey folks, I've been teaching myself ASP.net for the past 8 months as I've been taking over an existing application running ASP.net 1.1.  I've been testing successfully on my local machine using a small data set but I recently found an issue when the same code was being used on the production server.  In production, the data set (SQL Server 2000, btw) being queried is quite large and the stored procedure is fairly complex.  This adds up to a run-time for the stored procedure of around 2 hours.

The expected behavior of the page is as follows (and it works in ASP.net 1.1 mode):

  1. Choose criteria in the form and submit.
  2. Build stored procedure call and execute ( adapter.Fill(ds) ).
  3. Bind DataGrid to DataSource.
  4. Update a few labels, etc.

What is happening is that when IIS is configured to use ASP.net 2.0, it basically seems to stop after step 2.  The page churns for about an hour and a half and then stops as if it is finished.  However, the DataGrid is not displayed and none of the labels are updated.  It's almost as if it gave up interacting with the web controls.  Funny thing is, some steps ARE executed after the database call such as a write to the log file (see orange and green highlighting below).  So basically it looks like it finishes executing but anything referencing a web control is unable to complete.

While I come from an environment of responsive web applications, this one is used by only one or two people at a time and thus they are accustomed to clicking, leaving, and checking back later for the results.  Therefore I'm not looking for suggestions about asynchronous DB calls, which I'm sure would be a good end goal and the 'ideal' user experience for many.

Posting some of the code (not complete) below to give you an idea.  I appreciate anyone's insight into what may be causing this.

 

1    strSqlCode = "Execute " & strRepCode & " '" & sTaxYear & "','" & intCorrType & "','" & sSubFile & "', '" & sServCent & "', '" & sTreats & "'"
2                    
3    Write2Log(strSqlCode)
4    ' get report from SQL server
5    connx= New SqlConnection(Application("DSN"))
6    connx.Open()
7    cmdSelect = New SqlCommand(strSqlCode, connx)
8    cmdSelect.CommandTimeout = 10 * 60 * 60
9      
10   Dim myAdapter As SqlDataAdapter = New SqlDataAdapter()
11   myAdapter.SelectCommand = cmdSelect
12   Dim ds As DataSet = New DataSet()
13   
14   DataGrid2.Visible = True
15   'Load Data Set from XML file or refresh from Database
16   
17   myAdapter.Fill(ds)
18   
19   'Write out schema representation
20   ds.WriteXmlSchema(schemaFileName)
21   'Write out XML data form relational data
22   ds.WriteXml(reportFileName, XmlWriteMode.IgnoreSchema)
23   f = New IO.FileInfo(reportFileName)
24   modified = f.LastWriteTime
25   lblSavedReport.Text = "(Last Refreshed " & modified.ToShortDateString() & " " & modified.ToShortTimeString() & ")"
26   BtnRefreshReport.Visible = True
27   lblSavedReport.Visible = True
28   
30   DataGrid2.DataSource = ds
31   DataGrid2.DataBind()
32   
33   conAUR.Close()
34       
35   Finish = Timer    ' Set end time
36   TotalTime = Finish - Start    ' Calculate total time
37   sMsg = "Tool took " & Format(TotalTime, "###0.00") & " seconds to display " & lblResults.Text & ". More info: " & lblTYCorr.Text
38   Call Write2Log(sMsg)
 
New Post
6/4/2008 1:07 PM
 

I'm not sure where to begin.

How long does .NET 1.1 take? What is written to the log file? What is the session timeout? What is happening on the server itself (CPU)?

I can tell you that any SQL query that takes 2 hours does not belong in a web application or any user interface for that matter.

Have you considered using a different approach to get the same results?


Dwayne J. Baldwin
 
New Post
6/7/2008 9:11 PM
 

There are any number of timeouts that could be triggered while you are trying to run something this long inside a web application.
Frankly - it seems like a task that is not really suitable to be run this way.

Not sure where to start but first off - what sort of SQL query are you running in this world of processor power that 
takes 2 hours on a well optimised database.

The relevance dataset would have to be HUGE - is this an UPDATE query or just a SELECT.
If its just a SELECT then it feels like you need to look seriously at the database to take advantage of query index optimisation.

As for whats timing out -  can you put a try catch around the offending task and tell us what error is firing since there will be one firing somewhere.

At a guess it could be the worker thread getting killed because it seems to be dead - and the OS thinks it needs to do a salvage job.

If you really do need to run this sort of query inside a web application - is there any way to compartmentalise the query into sections
or blocks - maybe passing it thru a couple of temporary tables.

I also noticed that you are using a dataset to handle the returned data
 - is it possible that the result set is very large and overflowing the memory allocation of the application pool.

As a thought - you could possibly try using a datareader in your code instead of a dataset to get a better idea of where memory is being used etc.

Westa

 

 
New Post
6/9/2008 4:55 PM
 

Sorry it's taken me a while to get back but I don't have access to the server every day and when I do, I have other things going on plus testing this kind of thing is slow work.

Anyways, here are the answers to your questions Dwayne:

How long does .NET 1.1 take?

 About 75 minutes

What is written to the log file?

  Two lines; The first is the SQL command issued which calls the stored procedure
             A message that says how long it took to run (i.e. "The tool took X.x seconds to display the report").

What is the session timeout?

 10 minutes

What is happening on the server itself (CPU)?

 CPU is not very busy.  It hangs around 1-2 percent.

I can definitely look at a different approach if need be but I have a deadline and other things to finish.  Unfortunately, the fact that running queries like this in real-time from the web interface is a BAD idea is completely beside the point for the folks that use the application.  They just want it working like it has been for a couple of years now and it didn't seem like too much to ask.  I didn't know switching to ASP.net 2.0 was going to cause so many problems.  In posting this, I was really just fishing to see if anyone had seen this type of problem crop up when simply switching from 1.1 to 2.0 mode in IIS.  So, far (here and other forums) no one has given me any real new information...which may mean there isn't any out there.

Thank you for your help...I'll let you know if I find a smoking gun.

 
New Post
6/9/2008 11:04 PM
 

I can only guess that something has been fixed in 2.0, and now behaves differently than 1.1. It could be memory allocation, garbage collection, or even a different setting in the framework or IIS.

Typically how I would handle this would be to run SQL profiler to see what is being submitted and how the results could be improved. Sometimes adding an index or two may improve performance by an order of magnitude or more, which in your case would be a few mintutes instead of hours.

I will bet that this can be significantly improved through reducing the data domain, changes to the data schema, indices, temp tables or a combination of such.

I would really need to see the actual data schema and the SQL request. Then I would spend one morning and make the web application respond in real time like it should.


Dwayne J. Baldwin
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ASP.net 2.0 issue with long queriesASP.net 2.0 issue with long queries


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out