-
Notifications
You must be signed in to change notification settings - Fork 87
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
update
should only update changed fields on record
#472
Comments
Doing this means we need something akin to the It's a good idea, I'm all for it. In AR it's not always clear if this is automatically enabled or not. I think this should come standard enabled so no one has to think hard about it. Link to the module so anyone else can check and get an idea of what's going on. This means we need to add:
My first thought is that we should probably do this with a hash that takes all values in as That part is probably worth testing to confirm. |
We could possibly use the hashdiff lib i wrote: https://github.com/spoved/hashdiff.cr tho, it would require keeping a "pristine" record and "dirty" record to compare. which i dont know if i like. probably some sort of dirty flag and a record of which field was changed would be a better path. |
@kalinon I'd rather not introduce outside libraries into Granite if at all possible, and I think this is simple enough that including it in Granite itself should be easy to do. |
It seems like MySQL doesn't care about this: https://stackoverflow.com/questions/3186908/mysql-update-statement-overhead-for-same-values postgres might benefit from this: https://dba.stackexchange.com/questions/118178/does-updating-a-row-with-the-same-value-actually-update-the-row#:~:text=PostgreSQL%20is%20a%20database%20and,the%20new%20value%20or%20not. Can't tell how SQLite would perform from some quick googling. |
Currently Granite will perform an
UPDATE
and provide all fields for the update statement. It should only perform an update on the fields that changed for optimization.The text was updated successfully, but these errors were encountered: