Print Page | Close Window

New Paging system for Forum v9.51

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=26306
Printed Date: 03 April 2026 at 9:48am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: New Paging system for Forum v9.51
Posted By: moti
Subject: New Paging system for Forum v9.51
Date Posted: 27 September 2008 at 10:37pm
Hi
I just wanted to know why did u add a TOP in your queries, I think this will decrease performance Its no need to use TOP coz WHERE already did what TOP is doing
like this


SELECT * FROM (SELECT TOP (@intPageSize * @intRecordPositionPageNum) my_table.*, ROW_NUMBER() OVER (ORDER BY my_table.id DESC) AS RowNum

FROM my_table WITH (NOLOCK)

WHERE my_table.id = 2) AS PagingQuery WHERE RowNum BETWEEN @intStartPosition + 1 AND @intStartPosition + @intPageSize



Following Query do the same and without TOP


SELECT * FROM (SELECT my_table.*, ROW_NUMBER() OVER (ORDER BY my_table.id DESC) AS RowNum

FROM my_table WITH (NOLOCK)

WHERE my_table.id = 2) AS PagingQuery WHERE RowNum BETWEEN @intStartPosition + 1 AND @intStartPosition + @intPageSize
Could u explain for me why did u use TOP in ur query
I just checked these in SQL 2005 and execution plan for second query (without TOP is better)
 
Thanks



Replies:
Posted By: WebWiz-Bruce
Date Posted: 29 September 2008 at 10:40am
It reduces the number of records sent across the network, and in testing on large forums with over 500,000 posts it was found to be faster.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net