Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - New Paging system for Forum v9.51
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

New Paging system for Forum v9.51

 Post Reply Post Reply
Author
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post Topic: New Paging system for Forum v9.51
    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
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.