Error when updating multiple rows in same group #212
Replies: 3 comments 1 reply
-
[2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 1000, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.24} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 0, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.17} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 2, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.77} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 'true', "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.5} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 0, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.48} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 2, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.19} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 'false', "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.54} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 0, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.49} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 2, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.3} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 2000, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.14} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 1000, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.26} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 64, "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.47} [2023-03-27 19:24:39] local.DEBUG: update "settings" set "payload" = 'true', "updated_at" = '2023-03-27 19:24:39' where "group" = 'anyGroup' and "-------" = '-------' {"time":3.45} |
Beta Was this translation helpful? Give feedback.
-
I did a solution for this I would love to get your opinion on it.
|
Beta Was this translation helpful? Give feedback.
-
Could you send in a PR adding this? I think if all tests are green this one can be merged into the package. |
Beta Was this translation helpful? Give feedback.
-
Description:
When trying to update multiple rows which belong to the same group, our application is saving each value alone to the database, using a collection each method and looping through each property to update it individually. This is resulting in a significant performance hit, as it is generating multiple queries to the database, instead of updating all rows in a single query.
We have considered using the update method provided by Laravel's Query Builder or Eloquent ORM to update multiple rows in a single query, but we are encountering errors when attempting to do so.
Specifically, we are seeing errors related to mismatched data types or SQL syntax errors when attempting to use the whereIn method to specify the IDs of the rows to be updated, and then chain the update method to set the new values for the relevant columns.
We believe that this issue may be related to the structure or configuration of our database, or to the way that our models are defined. However, we are not sure how to diagnose or resolve the issue.
We would appreciate any guidance or assistance that can be provided to help us resolve this issue and improve the performance of our application.
Beta Was this translation helpful? Give feedback.
All reactions