-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of order by index optimization #1843
Comments
So this query:
When you've 10M of Customer records, how do you prefetch so many records? |
We do not need to. |
So without iterators how do you lazy browse results? |
Paginated range query is lazy browsing of results, for example com.orientechnologies.orient.core.index.sbtree.OSBTreeMapEntryIterator in reallity paginated query. |
I got what you mean how to do async queries on the fly, but it is already implemented using listeners - com.orientechnologies.orient.core.index.OIndex#getValuesBetween. All records loaded using com.orientechnologies.orient.core.index.OIndex.IndexValuesResultListener not collections. |
So do you mean to add a direction in OTreeInternal.loadEntriesMajor() to move forward and backward and use the OSBTreeMapEntryIterator to browse item? |
In such way it is up to listener how to process them. But only needed records will be loaded in ordered manner. |
I meant to add direction in com.orientechnologies.orient.core.index.OIndexEngine#getEntriesMajor and listener will follow through records in needed order. |
Gotcha, +1 |
Current order by optimization of queries is simple.
If we have small enough records in index and have non composite index we iterate through them.
But there is much more elegant idea of optimization of order by.
When we fetch data using index range query we can iterate through index in both directions descending and ascending so just by passing the flag of direction of iteration in index range query method we can provide much broader "order by" optimizations, actually we will simply not have restrictions of order by optimization which we have now.
Also very interesting point is that index iterators, they ask many additional memory areas to iterate which kill CPU cache locality for data which we really need to fetch so such proposed approach will be faster too.
Actually I would remove iterators from index at all.
They may be not thread safe either, because implementation com.orientechnologies.common.concur.resource.OSharedResourceIterator does not deal with thread safety of state between iterations.
Much efficient approach in this case is to introduce firstKey/lastKey methods in idex and use between queries. In such case we will iterate only through data which we need and will not prefetch unneeded data and drop iterators from index.
The text was updated successfully, but these errors were encountered: