Sort by timestamp DESC

Hi All,

This is my model:
{
“contentId”: “020b39ab-493a-46ea-9f9a-0684224a516a”,
“userId”: “XYZ”,
“properties”: “NoSpecificProperties”,
“timestamp”: 1563444505297
}

Assume that I have almost 1lakh records for this user, How do I sort the document by timestamp DESC using INDEX?

I tried,
CREATE INDEX favorites_timestamp_desc ON favorites(timestamp DESC);

select * from favorites use index(favorites_timestamp_desc) order by timestamp limit 50 offset 0

This is not working. Can somebody help?

CREATE INDEX favorites_timestamp_desc ON `favorites` (timestamp DESC);

select * 
from favorites use index(favorites_timestamp_desc) 
WHERE timestamp IS NOT MISSING
order by timestamp DESC
 limit 50 offset 0
1 Like

Thank You… It worked fine :slight_smile: