function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nicolas BragardNicolas Bragard 

"Order by" clause in SOQL

As I know there no way to sort information using SOQL. It would be find to have the "order by" clause available in SOQL

Of course I can sort the information once they are retrieved from salesforce.com but this is time consumming.

 I can understand that salesforce.com doesn't want to allow to order the result on the server side due to potential performance issues but I am sure that salesforce.com maintains several sorted indexes  in their database for Internal use. At least it would be fine to have a way to use existing indexes to retrieve information using index hints.

Ex:

Imagine that there is a sorted index on the account table based on the account name, called "IndexAccountName". It would be nice to write something like

"Select Name from account index IndexAccountName"

to retrieve the content of the account object sorted by name. This way salesforce.com will not have to take care of performance issues as only existing indexes could be used. I am sure that most of the existing sorted indexes used internally by salesforce.com could be useful for external use.

 

 

benjasikbenjasik
Thanks for the suggestion. Something we're considering for a future release.