berlindb / core

All of the required core code
MIT License
252 stars 27 forks source link

Stop updating the full row when trying to update only specific columns there. #98

Closed engahmeds3ed closed 3 years ago

engahmeds3ed commented 3 years ago

Introduction

Here: https://github.com/berlindb/core/blob/ac238c28b18bc2cfdf063f551e4900e14b0eec17/query.php#L1892 You are merging the DB item with the data being sent to be updated so if you want to update just one column in a row, you are actually updating the full row.

The problem

We have two problems here:-

  1. Performance issue: so in our case, we have rows with too large contents and when dealing with such large content we need only to update just the fields we need to update like when trying to update the small column last accessed time we don't need to grab the other big columns from DB and save them again, this will for sure consume resources and time.
  2. Data issue: In relation with this issue when tried to send the content after applying addslashes function on it, this solved the issue but if we tried to update any other column, this content column will have stripslashes applied on it and we never sent it to be updated!

Proposed solution

We need to only update the sent columns without grabbing the full row again from the DB, we may just making sure that the item exists only but without using its contents.