SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Paginating a SQL query result set


Paginating a SQL query result set

Author
Message
gjryan59
gjryan59
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 153
Comments posted to this topic are about the item Paginating a SQL query result set
Iwas Bornready
Iwas Bornready
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16110 Visits: 885
Seems kind of elaborate to replace:
select top 10 column1, column2, column3 from table where column1 > 99 order by column1
or
select top 10 column1, column2, column3 from table where column1 > (99 + (page * 10) )order by column1
gbritton1
gbritton1
SSC Eights!
SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)

Group: General Forum Members
Points: 823 Visits: 874
OFFSET/FETCH is the prefered method for pagination, I believe
trimjib
trimjib
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 316
As Ryan pointed out the real problem is with the query dataset not being utilized for subsequent page calls. The cost is in preparing the dataset, not in grabbing a few rows from it.

Does Offset/Fetch notify SQL to optimize that aspect of pagination?
gjryan59
gjryan59
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 153
The reason it is written the way it is, is that the underling data may change between page changes on the mobile devices that this was written for. Hence not cashing the dataset and just paging through it.
gbritton1
gbritton1
SSC Eights!
SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)SSC Eights! (823 reputation)

Group: General Forum Members
Points: 823 Visits: 874
trimjib (11/2/2015)
As Ryan pointed out the real problem is with the query dataset not being utilized for subsequent page calls. The cost is in preparing the dataset, not in grabbing a few rows from it.

Does Offset/Fetch notify SQL to optimize that aspect of pagination?



The previous results would be cached.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search