-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Batch or bulk updates #762
Comments
This should definitely be implemented mostly in C++ for better performance. |
The priority will be low as there are clear and easy workarounds for this. This is mainly a performance optimization. |
When it comes to code that makes changes in the database, the cost of the On Mon, Jan 19, 2015 at 9:41 AM, Brian Munkholm notifications@github.com
|
That all depends on the number of objects you want to update and if you persist to disk or possible in-memory. But commit to disk and updating few objects, you are right. |
The cost of commit does grow with the amount that is committed, the /Finn On Mon, Jan 19, 2015 at 11:16 AM, Brian Munkholm notifications@github.com
|
It would be great if a batch processing feature is implemented as this feature can add the IN clause. |
+1 Will really make things look prettier. |
What exactly is the workaround? Is it this:
I tried this and it doesn't update anything after 200 records for me, is there a limit or a soft fail if it reaches a memory threshold? I'm wrapping the above code in a |
@basememara It's a wrong idea to loop over a RealmResults while updating it. Since you're changing the RealmObjects (Foo in your case), the |
@Saketme It depends on where you begin your transaction. As
|
No, sorry not being clear earlier. I am talking about something else. This line of code get all
Now, if you iterate over it using a for-i loop, setting each item to "read", it will cause the On every iteration, on every item that gets marked as "read", the As a result, the for loop will skip every alternate item. |
@Saketme Well, you can do
|
Aha! That's a really nice idea :D Thanks! |
Seriously though, this is in iOS here: https://realm.io/docs/swift/latest/#key-value-coding Realm really will need something like this, because creating 3000 objects to update 3000 properties isn't very good for GC. |
I tend to agree. |
For reference: https://www.reddit.com/r/androiddev/comments/5npdk2/big_realmresult_how_to_iterate_through_all_of_it/, some users are hitting memory issues because of this, so we should probably prioritize getting it in relatively soon. |
Any chance of this one appearing any time soon? It's kinda a necessity for working with larger data sets. |
@cmelchior Out of curiousity, then |
@cmelchior @Zhuinden Realm Core doesn't have a such a setter so if we were to implement |
@kneth but iOS has this 😕
Creating a new object proxy for each updated element is bad for memory usage |
@cireficc You realize, of course, that this will simply put that loop in our code, instead of yours ;-P |
@bmeike if you can move that loop off the Java heap, that'd be great for larger data sets though 😜 |
Yes, that is the primary reason to move this into c++. It becomes zero-allocation on the Java side. |
@bmeike Exactly, then my code will be just a tad bit cleaner ;P |
Technically the real thing here is that updating would take O(N) memory which is bad, SQLite can do this with UPDATE without any allocation. So this will help remove a possible bottleneck in Realm if you ask me |
So, uh, is this still in RMP 2.0 milestone? (and how did I unassign bmeike? that is odd. oh well) |
@Zhuinden Maybe you are the magician? |
@Zhuinden Yes, this is still scheduled for RMP 2.0 milestone, but not a high priority so if things get tight you have to wait for 4.1 😄 |
Any updates, we are in |
It seems there is a snapshot concept, for at least a natural iterate/update scenarios: https://realm.io/docs/java/latest/#iterations-snapshots |
In my Android application I has pojo:
Suppose in Realm table I has 100 products. Nice. I need something like this:
How I can do this? Thanks. |
Should work |
Support has been added in #5133. It will be part of 5.8.0 |
Rejoice! 🎊 🎉 🎈 🍾 🎆 |
I thought you might like it 😉 |
Feature request following this discussion: https://groups.google.com/forum/#!topic/realm-java/6NeywfWmCA4
Basically it allows setting a property on many objects in one operation just like this SQL:
One option could be
The text was updated successfully, but these errors were encountered: