Analytics and Order By

Please, help!
I try to use Analytics Query with order by

SELECT  _scope, id, updated_at
  FROM orders   
  ORDER BY  id      limit 12

I created index by id

CREATE INDEX idx ON orders   (id :string) ;

But in the query plan I don’t see that the index is used, so the query is long (>1s). How can I make analytics sort by index?

Same problem if I do sorting by updated_at with index

CREATE INDEX idxUpdated ON orders(updated_at:DATETIME) ;

Is it really possible to use queries in analytics with sorting or maybe it is not designed for this?

Hi @Lenty_Me,
You can use sorting in Analytics queries, but Analytics secondary indexes are not currently utilized for sorting operations.

For the example query you provided, all the data in the collection orders will first be sorted on the id field, then a global limit for the top 12 will be applied.

It’s very sad, we’ll wait for the analytics service to be updated,
In the current release, queries with sorting take a very long time.