-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support update() with conditions #76
Comments
I'm against extending the API to have methods that are created for the bulk update of whole spaces. This has the ability to lock the whole instance for a long time. |
Big selects have the same ability, and delete operation has been already supporting conditions. It is a matter of a convenient API and not forcing customers to write boilerplate code. Consider the case when we substitute UPDATE .. WHERE SQL operation with a CRUD analog. Should we load data one by one from a large space to the client or maybe updating it in place is better? |
That's why we will incur the same limitation we have for selects as we have in Data Grid. There will be a limit on how many rows a select can scan before returning with an error. Unbound selects shouldn't be allowed. Yes, I believe it's better to pull data to the client and then update it in batches. It will keep the database operational at least. Doing an update that touches the whole data set will just freeze the database. If you want to do an update of around 1-10 items, then pulling them to the client should not be a problem. If you want to update the whole table, then you've clearly picked the wrong way to implement it. |
Updating whole datasets should be done by a background task. |
If you mean "asynchronous" task which reports events about its state, it is a good case and may be supported in the connectors. So the users may wait or not until the task finishes, which depends on the business scenario. In this case, it seems like an implementation detail, and the update API may look like the proposed above. Btw, the delete() operation has the same API now. |
It looks like "select for update" and I am afraid it is less efficient than the built-in in-place update. |
The I already told you that we won't support mass updates from the |
But what do you think about the mass updates in an asynchronous task which returns a future and produces events? Batch update using small portions of data may be implemented in CRUD this way. |
The current API is stateless and doesn't support long-running tasks. And the basic CRUD operations won't be stateful by design. This is a deliberate choice. In the future, it is possible that we will make some sort of background tasks, but I will resist it unless there is a solid argument for why they are useful. For now, use "select for update". It should solve most of your problems. |
We discussed it with the product team and decided to don't implement it here. Sorry, Alexey. |
Use case: customer wants to update a single field value in a large sharded space with some conditions. For example, change statuses of all orders with status "PAYMENT_RECEIVED" to "CLOSED".
Proposed API variants:
a) Allow update() method to receive conditions instead of key parts:
b) Add a new method updateall() (the method name may be different):
The same variants may be used for the upsert() operation.
The text was updated successfully, but these errors were encountered: