DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

SQL page load performance

 8 Replies
 2 Subscribed to this topic
 26 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 5
New Around Here

Hello all. I have inhereted an outdated DNN site... tere is a module which loads data from an SQL (2016) table that is on the larger side. This table contains inventory, so it can't really be shrunk in any way. The DB Performance is really good. Other applications (NAV) can load the same table in 3-5 seconds.

For instance: The page displays the first 10 results of around 6500 records, so there's a total of 650 pages. This takes 30+ seconds to load and makes users grumpy and they like to whine. 

My thoughts to speed up would be something like:

  • Cache this table data and update it every 10-15 min?
  • Dynamicly load the data... It doesn't display untill it's ALL loaded, can it display page 1 and then contine loading in the background?

If anyone has a suggestion I would like to hear them! Thank you.

Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!

Hi,

these articles are a bit old, but they should give you the idea of how to load only the records needed to display on one page (which makes the thing more efficient and faster, as not all records are returned from SQL Server):

ScottGu's Blog - Efficient Data Paging and Sorting with ASP.NET 2.0 and SQL 2005

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
Veteran Member
Posts: 546
Veteran Member
MVP
MVP
You're an MVP!
loading 6500 rows should not take 30 secs, unless each row is rather large (> 11 KB) or it takes time for the database to fetch the rows. did you monitor execution of the query using SQL Server Profiler or Activity Monitor?
New Around Here
Posts: 5
New Around Here

Michael, Thank you but the article pertaining to SQL is dead. 

Sabastian, All of the monitoring seems to be withing reason. There's tons or RAM and resources available. As I mentioned before, it loads right up to a Microsoft NAV client, but seems to take forever to post to IIS.

Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!

Hi again,

sorry about this... the basic idea is to create a stored procedure and pass the page number and the number of rows to get only the data that will be actually displayed on the page.

Here is an example:

<code>CREATE PROCEDURE &#91;dbo&#93;.&#91;GetProductsByCategoryId&#93;<br />    @CategoryId INT,<br />    @PageIndex INT,<br />    @NumRows INT,<br />    @CategoryName nvarchar(50) OUTPUT,<br />    @CategoryProductCount INT OUTPUT<br /> AS<br /> BEGIN<br />    /*<br />       The below statements enable returning the Total Product Count and friendly Name for the CategoryId<br />       as output paramsters to our SPROC. This enables us to avoid having to make a separate call to the<br />       database to retrieve them, and can help improve performance quite a bit<br />     */<br /> <br />    SELECT @CategoryProductCount = (SELECT COUNT(*) FROM Products WHERE Products.CategoryId = @CategoryId)<br />    SELECT @CategoryName = (SELECT Name FROM Categories WHERE Categories.CategoryID = @CategoryId)<br /> <br />    /*<br />       The below statements use the new ROW_NUMBER() function in SQL 2005 and later to return only<br />       the specified rows we want to retrieve from the Products table<br />    */<br /> <br />    DECLARE @startRowIndex int;<br />    SET @startRowIndex = (@PageIndex * @NumRows) + 1;<br /> <br />    WITH ProductEntries AS (<br />       SELECT<br />          ROW_NUMBER() OVER (ORDER BY ProductId ASC) AS Row,<br />          ProductId,<br />          CategoryId,<br />          Description,<br />          ProductImage,<br />          UnitCost<br />       FROM Products<br />       WHERE CategoryId=@CategoryId<br />    )<br /> <br />    SELECT ProductId, CategoryId, Description, ProductImage, UnitCost<br />    FROM ProductEntries<br />    WHERE Row BETWEEN @startRowIndex AND @StartRowIndex + @NumRows-1<br /> <br /> END</code>

I hope this gives you the idea of how to handle it. What you need is:

  • current page number
  • total number of records
  • number of records per page

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
Veteran Member
Posts: 546
Veteran Member
MVP
MVP
You're an MVP!
Posted By JKeller on 17 Feb 2022 08:39 AM

..

For instance: The page displays the first 10 results of around 6500 records, so there's a total of 650 pages. This takes 30+ seconds to load and makes users grumpy and they like to whine. 

this sounds more like a timeout than a performance problem of SQL or IIS server. 

 

New Around Here
Posts: 5
New Around Here

Right, I'm juggleing two differernt problems. People complaining it takes too long, and when it does take over 30 seconds it times out.

I have searched high and low to find the reason for a hard 30s timeout but I can't find anything. I've tried a 100 different things so far!

w3wp.exe seems to be the processes that throws the error.

Veteran Member
Posts: 546
Veteran Member
MVP
MVP
You're an MVP!
a timeout happens, if the database doesn't return expected result or really has performance issues. But if you don't experience this issue using the same query from a different application there must be a problem in the code of your module.
New Around Here
Posts: 0
New Around Here

I second Sebastians thoughts - perhaps other applications using 'this' statement are missing a specific column? Perhaps an index have been created for 'this' select statement - but you have included an extra column which is not part of the index? If this is the case the performance will take a big hit since the SQL server will have to extract the data from the table instead of the index.

This can usually be determined by monitoring the SQL server while DNN is extracting the data (using the activity monitor in SSMS - see Active Expensive Queries or Recent Expensive Queries). Catch the executed select statement and try executing it in SSMS with the execution plan option enabled (Ctrl+M). This will give you a detailed view of where the performance bottleneck is - and whether the SQL have any impact on it!

If the SQL is not the bottleneck it is most likely the architecture/technology of the module you need to look into.. but that will require having access to the source code.

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

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

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. 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.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved