Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 16th, 2005, 03:57 AM
Registered User
 
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default rise speed for "sp_Forums_GetTopicsByPage"

This is a StoreProcedure in Forums module.
It used to get topics by @PageNumber, @PageSize.
.....
INSERT INTO #TempTopics
(
    TopicID,
    Subject,
    AddedDate,
    TopicReplies,
    TopicLastReplyDate,
    TopicLastPostDate,
    MemberID,
    MemberName,
    Email,
    ShowEmail
)
SELECT
    TopicID,
    Subject,
    AddedDate,
    TopicReplies,
    TopicLastReplyDate,
    TopicLastPostDate,
    MemberID,
    MemberName,
    Email,
    ShowEmail
FROM
  v_Forums_Topics WHERE ForumID = @ForumID ORDER BY TopicLastPostDate Desc
....
I think if there have many records from views,you select all every page,not very good.So I think if can use "TOP".

Last I found use "SET ROWCOUNT " can do it.

Now ,it looks like this:

.....
-- fill the temp table with all the topics for the
-- specified forum retrieved from the v_Forums_Topics view
DECLARE @TopSize int
SET @TopSize = (@PageNumber* @PageSize)
SET ROWCOUNT @TopSize


INSERT INTO #TempTopics
(
    TopicID,
    Subject,
    AddedDate,
    TopicReplies,
    TopicLastReplyDate,
    TopicLastPostDate,
    MemberID,
    MemberName,
    Email,
    ShowEmail
)
SELECT
    TopicID,
    Subject,
    AddedDate,
    TopicReplies,
    TopicLastReplyDate,
    TopicLastPostDate,
    MemberID,
    MemberName,
    Email,
    ShowEmail
FROM
  v_Forums_Topics WHERE ForumID = @ForumID ORDER BY TopicLastPostDate Desc

SET ROWCOUNT 0

-- declare two variables to calculate the range of records to extract for the specified page
.....

The same as "sp_Forums_GetRepliesByPage"

I think this can raise your speed.
I am a Chinese,my English not good!
Thank you!

 
Old December 19th, 2005, 08:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's a good idea!

There's another trick to this that avoids using "top". The idea is that you have a good primary key column, and you know RowCount will limit the rows you retrieve, so you can just remember the highest primary key value that you retrieved the first time, and make sure your next fetch takes only primary key values greater than that.

This article explains it:
http://www.codeproject.com/aspnet/PagingLarge.asp

SQL Server 2005 has a new method of paging results that is even better. This will be covered in the second edition.
 
Old December 20th, 2005, 02:44 AM
Registered User
 
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to see your next version book,it really a good book for me,thank you!






Similar Threads
Thread Thread Starter Forum Replies Last Post
speed umeshtheone VB Databases Basics 2 May 21st, 2007 04:12 PM
Speed up macro EricB123 Excel VBA 1 April 30th, 2007 11:39 AM
CPU Speed soccers_guy10 Pro VB 6 4 February 6th, 2004 12:14 AM
rise event from panel [email protected] ASP.NET 1.0 and 1.1 Basics 3 January 30th, 2004 03:49 PM
Speed kilika SQL Server 2000 10 July 1st, 2003 06:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.