« Bring on the Java Developers! | Main | Select all records created before/after ___ with SOQL »

Offset Pagination Coming to SOQL

I can't begin to tell you how excited I am about this addition! This is a major performance improvement for those of us trying to go through large result sets returned with a SOQL statement. By giving us the new OFFSET, we can now specify the starting row offset as part of the query results. 

Basically, this is a nice and painless way for us developers for paging through large result sets and quickly jumping to a particular subset row. As an example, let's say you want to return a list of products to a user in a table and show them 50 at a time with a back/next option to page through the results. When the user skips to page Two in the result set, we want to start with the 51st record in the query result set. Previously we had to jump through some hoops to accomplish that in Apex/SOQL. Now, with OFFSET it's pretty darn easy.


   FROM VendorProducts__c

WHERE ModelYear__c > '2001'


   LIMIT 50


This accomplishes what we were trying to do by showing us a resulting set of 50 records that begins with the 51st record in that query result set. LOVE IT!

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
All HTML will be escaped. Hyperlinks will be created for URLs automatically.