-
Notifications
You must be signed in to change notification settings - Fork 579
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
Time complexity of operations #162
Comments
Thanks for the suggestion and I totally agree. |
You've mentioned earlier that SET has a time complexity of log(mn), I am assuming one is the number of points in the set, what is the other? If I have 1 set with 100 points I can easily update them 20k/s, but when I have 10k sets with 100 points each (1 million points in total), latency goes up a lot, is the total number of points in the DB also a factor? I have a lot of points that I keep track of, with lots of updates but almost no get/search queries, so any boost in SET performance would greatly help :) Edit: |
The Setting a point requires two operations:
The btree insert complexity is O(log n). The more points you add the slower it gets but eventually it should level out.
You will probably not see much in the way of a performance benefit from splitting up the data set over multiple collections because the collection must be located prior to setting the point. Collections are mainly good for organizing your data like namespaces. |
I see, I thought each collection would keep its own btree and rtree, thus having faster performance for smaller sets. From my testing it does seem to level out when more points are added. |
Each collection does have it's own btree and rtree, but the collections themselves are stored in a parent btree. So each SET must traverse the parent btree first. As far as overall complexity goes, the collection btree is just an extension of the parent btree. Thus not adding any real benefit. If the collections were stored in a different structure such as a hashmap, then we would see a bonus... at the expense of not having ordered keys. |
@tidwall
I think you have a good grasp of the (avarage/estimated) time complexity of operations. I think it would be a good idea to document these in the commands section. This would be especially useful for: SET, GET and the search commands. It might also be useful for FSET, JSET, KEYS ect.
The text was updated successfully, but these errors were encountered: