How to query latest record with param LIMIT and SKIP without ORDER BY DESC?

20 views
Skip to first unread message

jkchin

unread,
May 23, 2017, 3:35:46 AM5/23/17
to OrientDB
I met a querying performance problem  while using a SQL like "SELECT FROM MyClass WHERE Some-condition  ORDER BY PROPERTY1  LIMIT 10 SKIP ###" and ORDER BY consume to much time in my case for lots of records. 

without the "ORDER BY " , the results returned very fast but they are the earliest records, but I need it return the latest . I'm not using lightweight edge and index. Is it possible to get the latest results without ORDER command? 

Luigi Dell'Aquila

unread,
May 23, 2017, 3:40:51 AM5/23/17
to orient-...@googlegroups.com
Hi, 

There is no specific syntax to retrieve last records of a query without an ORDER BY, but you can define an index on PROPERTY1, this will speed up the sorting. Just consider that you cannot use two different indexes, one for filtering and one for sorting, so you have to choose.

I hope it helps

Thanks

Luigi


2017-05-23 8:30 GMT+02:00 jkchin <bill19...@gmail.com>:
I met a querying performance problem  while using a SQL like "SELECT FROM MyClass WHERE Some-condition  ORDER BY PROPERTY1  LIMIT 10 SKIP ###" and ORDER BY consume to much time in my case for lots of records. 

without the "ORDER BY " , the results returned very fast but they are the earliest records, but I need it return the latest . I'm not using lightweight edge and index. Is it possible to get the latest results without ORDER command? 

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages