Click here to Skip to main content
15,910,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
SELECT
    ROW_NUMBER() OVER (ORDER BY Item_ID) AS ROW_NUM
    ,I.[ITEM_ID]
    ,I.[ITEM_NBR]
    ,I.[ITEM_CATEGORY_ID]
    ,I.[ITEM_CATEGORY_NAME]
FROM INV_ITEM_MASTER as I


I have view query as above
however i found performance issue work with big data using that query cause by OW_NUMBER() OVER (ORDER BY Item_ID) AS ROW_NUM


any suggestion to avoid using row number as above?
cause i still need use it for paging
Posted
Comments
Suvendu Shekhar Giri 28-Jul-15 2:07am    
Check this article. Awesomely done.
A More Efficient Method for Paging Through Large Result Sets
Hope, you'll find it useful.

1 solution

There are a lot of techniques how to implement paging. For example have a look at Paging of Large Resultsets in ASP.NET[^]

However, if that is the whole query you use, you seem to be missing boundaries for the fetch, so you select everything from the database and do the paging on client side. I believe that the query should be something like
SQL
SELECT TOP 10 a.* 
FROM ( SELECT ROW_NUMBER() OVER (ORDER BY Item_ID) AS ROW_NUM
              ,I.[ITEM_ID]
              ,I.[ITEM_NBR]
              ,I.[ITEM_CATEGORY_ID]
              ,I.[ITEM_CATEGORY_NAME]
       FROM dbo.zipcode ) a
WHERE ROW_NUM > @start_row_number
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900