Skip to content
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

Updated GetNextIdValue to get actual next Id #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Updated GetNextIdValue to get actual next Id #13

wants to merge 1 commit into from

Conversation

qpooqp
Copy link

@qpooqp qpooqp commented Jun 18, 2018

Potential fix for issue #3.

I'm taking all id values and then picking the max value from them.

@ttu
Copy link
Owner

ttu commented Jun 20, 2018

Would you like to add a benchmark that adds e.g. 1k, 10k, 100k etc. items to collection? With that we could compare how much this will slow down inserting new items.

I can't see any other solution for this so if this slows down insert a lot, maybe we have to add some limit e.g. for collections under 1000 items we go through all items and for over 1000 items just take last item's id.

@qpooqp
Copy link
Author

qpooqp commented Jun 21, 2018

I tried to make some benchmarks, but the performance was worse than i thought. 😄 I made some improvements, but i need to polish it a little bit. Give me some time and i will commit the code.

@ttu
Copy link
Owner

ttu commented Jun 22, 2018

There is some ugly solutions to try e.g.

  • Serialize and find id value from the text or JObject
  • Find value with reflection

Not sure if these will be any faster.

DocumentCollection could have latest id value stored in a variable. Should be lazy so won't be calculated unless needed. This should improve performance.

@qpooqp
Copy link
Author

qpooqp commented Jun 23, 2018

Interesting idea to store the latest ID in variable. I will try to use this approach.

@qpooqp
Copy link
Author

qpooqp commented Jun 28, 2018

Hello. I just want to give you some update.

I'm quite far, but still struggling with some cases. Main problem is when there is string ID. I can't easily compare it and when it gets mixed up with int IDs then it causes problems too.
But i will try to resolve this and then i will let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants