0

The default behavior for usergrid collection seems to be the entities that were added first are retrieved first when doing a GET. Can I have the entities retrieved in the reverse order, i.e. the entities added last are retrieved first. I know I can do it using a query ql=select * order by created desc but will this always mean sorting the results (having performance implications) ?

For e.g If I have a usergrid collection of Blogs then I need to get the latest blog first without having to do order by.

How do we achieve this ?

nilesh
  • 35
  • 3
  • Using order by is the only way to achieve this. However, you shouldn't suffer any significant performance hit using order by. Are you seeing performance problems using it? – rockerston Feb 16 '15 at 14:09
  • Thanks @rockerston for your reply. I assumed that using a order by especially if the collection has a large number of rows would result in degraded performance due to the additional sorting that we do on the results. I have not compared the performance of the plain query versus the order by query. – nilesh Feb 17 '15 at 05:05
  • If you are using 1.0, then there will be a performance hit, especially with a query. 2.0 uses ElasticSearch so the impact is not as significant. – rockerston Feb 18 '15 at 20:33

1 Answers1

0

With the addition of ElasticSearch in the 2.x architecture order by ascending can be achieved with decent performance. Please try this per the documentation here: http://apigee.com/docs/app-services/content/querying-your-data

Jeff West
  • 1,563
  • 9
  • 11