Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am working with WCF Services where we are exposing data as per client request. We have service which returns data for grid and this is where paging comes into picture. As of now We are using SQL 2008 which doesn't allow us to use fetch next.

So we are executing entire query every-time to return 10 rows. Is there any alternate solution so that for next call we can directly return data without executing query every-time.

My findings:

1. Use Caching: It may happen that caching may go down with large data and simultaneous calls from multiple user.

2. I can create new table where I will dump data from query with row number and with next call, I will return data from table. On first call we can return unique identifier which will be passed for next call to identify request. Personally I feel this bit complex and I don't think no one will agree on it.

Can you suggest some more ways ???
Posted
Updated 30-Mar-15 2:23am
v2
Comments
John C Rayan 30-Mar-15 11:41am    
Why can't you use Cache just for storing pointers(row keys) to the table so that in subsequent calls you will have to fetch only the required data.
deepakdynamite 31-Mar-15 5:21am    
thanks John, I havn't got your point completely.. Can you please elaborate ?
John C Rayan 31-Mar-15 7:53am    
Before explaining my solution can you confirm few details. How many clients are you servicing? Is 10 the maximum of rows as the result of your query. Where is the paging coming into picture here if only 10 rows to be displayed.
deepakdynamite 3-Apr-15 4:55am    
We have around 30 clients... and we got more than 10 records... I can't give you exact number but Yes I know that it would be more than 10 and can got beyond 50.
John C Rayan 6-Apr-15 13:48pm    
In the first call fetch the rows , the total of number of rows and current counter (10 initially). Store the first record identifier , last identifier, current counter and the total no of rows into the cache against the client (you can use sessionid or some other way). In the subsequent calls, check the number of rows against the current counter , if current counter 10 and total number of rows 10 then you dont have to execute query as you have already fetched all rows. If total rows greater than current counter then you have to fetch only the next 10 rows from the last record identifier and update the cache with the current values. repeat the same.

Hope this explains you better.

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