Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

$4.95 Windows Hosting at Webhost4life.com
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

Salaro -- Skins and more
OnyakTech
The best choice for your web site host, email hosting, and domain registration.
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  Forum Module [L...  sugession: Tuning 'Forum_Thread_GetAll'
Previous Previous
 
Next Next
New Post 6/6/2008 3:57 AM
User is offline Yoshihiro Kawabata
4 posts
10th Ranked


sugession: Tuning 'Forum_Thread_GetAll' 

Hello,

Stored Procedure 'Forum_Thread_GetAll' turning idea.
After rewrite this, This stored Procedure's exectue time became 50 times faster on our DNN site.

Test Environment:

  DotNetNuke: 4.8.3
  Forums: 04.04.03

Rewrited 'Forums_Thread_GetAll'

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[Forum_Thread_GetAll]
    (
      @ModuleID INT,
      @ForumID INT,
      @PageSize INT,
      @PageIndex INT,
      @Filter NVARCHAR(500),
      @PortalID INT
    )
AS
    DECLARE @sql NVARCHAR(2000) 
    DECLARE @PageLowerBound INT
-- Set the page bounds
    SET @PageLowerBound = @PageSize * @PageIndex
 
-- Create a temp table to store the select results
    CREATE TABLE #PageIndex
        (
          IndexID INT IDENTITY(1, 1)
                      NOT NULL,
          ThreadID INT
        )

    IF @ForumID IS NULL
        SELECT  @ForumID = -1
-- INSERT into the temp table
-- Create dynamic SQL to populate temporary table 

-- [ NEW: 2008/06/04 kawabata
    SELECT  @sql = 'INSERT INTO #PageIndex (ThreadID)' + ' SELECT T.ThreadID' + ' FROM dbo.Forum_Threads T' + ' WHERE T.ThreadID IN' +
'   (SELECT TOP ' + CONVERT(VARCHAR, @PageSize + @PageLowerBound) + ' T.ThreadID' + '     FROM dbo.Forum_Threads T' +
'     INNER JOIN dbo.Forum_Posts FP ON T.ThreadID = FP.ThreadID' + '     INNER JOIN dbo.Forum_Posts LP ON T.ThreadID = LP.ThreadID' +
'     INNER JOIN dbo.Forum_Forums F ON T.ForumID = F.ForumID' + '     INNER JOIN dbo.Forum_Groups FG ON F.GroupID = FG.GroupID' +
'     WHERE FG.ModuleID = ' + CONVERT(VARCHAR, @ModuleID) + '     AND (T.ForumID = ' + CONVERT(VARCHAR, @ForumID) + ' OR (' + CONVERT(VARCHAR, @ForumID) + ' = -1 AND F.PublicView = 1 AND T.IsPinned = 0))' +
'     AND LP.PostID = T.LastPostedPostID AND FP.PostID = T.ThreadID' +
'     AND (FP.IsApproved = 1)  AND (FP.IsLocked = 0) ' + @Filter +
'     ORDER BY T.IsPinned DESC, LP.CreatedDate DESC)'
-- ] NEW: 2008/06/04 kawabata
-- [ OLD: 2008/06/04 kawabata
--    SELECT  @sql = 'INSERT INTO #PageIndex (ThreadID)' + ' SELECT T.ThreadID' + ' FROM dbo.Forum_Threads T' + ' WHERE T.ThreadID IN' +
--'   (SELECT TOP ' + CONVERT(VARCHAR, @PageSize) + ' T.ThreadID' + '     FROM dbo.Forum_Threads T' +
--'     INNER JOIN dbo.Forum_Posts FP ON T.ThreadID = FP.ThreadID' + '     INNER JOIN dbo.Forum_Posts LP ON T.ThreadID = LP.ThreadID' +
--'     INNER JOIN dbo.Forum_Forums F ON T.ForumID = F.ForumID' + '     INNER JOIN dbo.Forum_Groups FG ON F.GroupID = FG.GroupID' +
--'     WHERE FG.ModuleID = ' + CONVERT(VARCHAR, @ModuleID) + '     AND (T.ForumID = ' + CONVERT(VARCHAR, @ForumID) + ' OR (' + CONVERT(VARCHAR, @ForumID) + ' = -1 AND F.PublicView = 1 AND T.IsPinned = 0))' +
--'     AND LP.PostID = T.LastPostedPostID AND FP.PostID = T.ThreadID' +
--'     AND (FP.IsApproved = 1)  AND (FP.IsLocked = 0) ' + @Filter + '     AND T.ThreadID NOT IN' +
--'       (SELECT TOP ' + CONVERT(VARCHAR, @PageLowerBound) + ' T.ThreadID' +
--'          FROM dbo.Forum_Threads T' +
--'          INNER JOIN dbo.Forum_Posts FP ON T.ThreadID = FP.ThreadID' +
--'          INNER JOIN dbo.Forum_Posts LP ON T.ThreadID = LP.ThreadID' +
--'          INNER JOIN dbo.Forum_Forums F ON T.ForumID = F.ForumID' +
--'          INNER JOIN dbo.Forum_Groups FG ON F.GroupID = FG.GroupID' +
--'          WHERE FG.ModuleID = ' + CONVERT(VARCHAR, @ModuleID) +
--'          AND (T.ForumID = ' + CONVERT(VARCHAR, @ForumID) + ' OR (' + CONVERT(VARCHAR, @ForumID) + ' = -1 AND F.PublicView = 1 AND T.IsPinned = 0))' +
--'          AND LP.PostID = T.LastPostedPostID AND FP.PostID = T.ThreadID' +
--'          AND (FP.IsApproved = 1)  AND (FP.IsLocked = 0) ' + @Filter +
--'          ORDER BY T.IsPinned DESC, LP.CreatedDate DESC)' + ' ORDER BY T.IsPinned DESC, LP.CreatedDate DESC)'
-- ] OLD: 2008/06/04 kawabata
PRINT @sql
EXEC ( @sql )

-- [ ADD: 2008/06/04 kawabata
 DELETE FROM #PageIndex
 WHERE IndexID <= @PageLowerBound
-- ] ADD: 2008/06/04 kawabata

    SELECT  FP.Subject,
            FP.Body,
            FP.CreatedDate,
     FP.UserID As StartedByUserID,
            LP.CreatedDate AS LastPostedDate,
            T.ThreadID,
            T.Views,
            T.ForumID,
            T.LastPostedPostID AS LastApprovedPostID,
            T.ObjectID,
            T.IsPinned,
            T.PinnedDate,
            FP.IsClosed,
            T.ThreadStatus,
            T.AnswerPostID,
            T.Replies,
            ISNULL(( SELECT COUNT(TR.ThreadID)
                     FROM   dbo.Forum_ThreadRating TR
                     WHERE  TR.ThreadID = T.ThreadID
                   ), 0) AS RatingCount,
            ISNULL(( SELECT AVG(TR.Rate)
                     FROM   dbo.Forum_ThreadRating TR
                     WHERE  TR.ThreadID = T.ThreadID
                   ), 0) AS Rating
    FROM    dbo.Forum_Threads T
            INNER JOIN #PageIndex PageIndex ON T.ThreadID = PageIndex.ThreadID
            INNER JOIN dbo.Forum_Posts FP ON T.ThreadID = FP.PostID
            INNER JOIN dbo.Forum_Posts LP ON T.LastPostedPostID = LP.PostID
    ORDER BY T.IsPinned DESC,
            LP.CreatedDate DESC

    SET @sql = 'SELECT COUNT (DISTINCT T.ThreadID) AS TotalRecords' +
' FROM dbo.Forum_Threads T ' + ' INNER JOIN dbo.Forum_Posts FP ON T.ThreadID = FP.ThreadID' +
' INNER JOIN dbo.Forum_Posts LP ON T.ThreadID = LP.ThreadID' + ' INNER JOIN dbo.Forum_Forums F ON T.ForumID = F.ForumID' +
' INNER JOIN dbo.Forum_Groups FG ON F.GroupID = FG.GroupID' + ' WHERE FG.ModuleID = ' + CONVERT(VARCHAR, @ModuleID) +
' AND (T.ForumID = ' + CONVERT(VARCHAR, @ForumID) + ' OR (' + CONVERT(VARCHAR, @ForumID) + ' = -1 AND F.PublicView = 1 AND T.IsPinned = 0))' +
' AND LP.PostID = T.LastPostedPostID' + ' AND FP.PostID = T.ThreadID' + ' AND (FP.IsApproved = 1) AND (FP.IsLocked = 0) ' + @Filter
 
    EXEC ( @sql )

Regards,

Yoshihiro Kawabata
dotnetnuke.jp

 
New Post 6/6/2008 9:30 AM
User is offline Matthias Schlomann
1487 posts
www.taunusstein.org
6th Ranked








Re: sugession: Tuning 'Forum_Thread_GetAll' 

Thanks Yoshihipo,

I have added your suggestion to our gemini, so I think it will be added in the next release.


Regards
Matthias
www.moonlightradio.net
Chat with me via MSN
 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  Forum Module [L...  sugession: Tuning 'Forum_Thread_GetAll'
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


MaximumASP
MaximumASP provides a wide array of web hosting plans to fit any hosting need. We also provide software and services needed to keep it running optimally.
MaximumASP.com
Mad Development: dotnetnuke design and development
We are an expert Dotnetnuke shop specializing in developing solutions that merge the requirements of design and branding, content management, ecommerce, search engine optimization and business logic.
www.MadDevelopment.com
telerik
telerik r.a.d.controls suite is the most innovative and comprehensive toolset for ASP.NET development, tailored for seamless integration with the DotNetNuke project. This integrated collection of controls allows professionals to build web-solutions with the UI richness and responsiveness of desktop applications.
dnn.telerik.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP