# Performance Impact of Optimization Methods on MySQL Document-Based and Relational Databases
## 5 Performance Tests--Results and Analysis
### Update Operation
#### 5.2.1 Updating a Single Item  
First, updating a single item and a single field was performed, by changing the name of a business; the update operation that was performed is presented in Table 4.  
In both cases, if there is no _business_ with a given _id_, no exception will appear, no element will be modified, and the query will run successfully. In the case of using document-based MySQL, we used the predefined _modify()_ method which takes the element search condition, the part of the query that follows \"where\", as a parameter, and then the _set()_ method was called, which changes the value of the field passed as the first parameter with the new value passed as the second parameter.  
Second, updating the same item but multiple fields was performed, as presented in Table 5.  
In the case of relational MySQL, for updating several fields, the fields we wanted to update were separated by commas, after the keyword _set_. In the case of document-based MySQL, after we filtered the element we wanted to modify, as in the previous case, using the _set()_ method, we modified the desired fields with the new values.  
Modifying a single item involves finding the element and then modifying it. The difference between changing one or more fields does not have a more significant impact in either document-based MySQL or relational MySQL, the differences being minor, as shown in Figures 4 and 5.  
For a small number of elements, the times are very close because the search was conducted after the primary key that already contains the index; after the subsequent addition of the other indexes and the optimization of the entity structure, the times improved relatively little, but with the increase in the number of elements, the time became slower for relational MySQL compared to document-based MySQL, the trend being maintained even after optimization.  
For update operations, optimizing the length of the fields and adding the indexes on the columns that change brought a small improvement in the response times, namely, an improvement of about 20%.  
\begin{table}
\begin{tabular}{r} \hline \hline
**Relational MySQL: Update a Single Item and a Single Field Operation** \\ \hline @Query(value = “update business set name = name \\ where id = :businessId”, nativeQuery = true) \\ void updateBylId(@Param(“name”) String name, @Param(“businessId”) long businessId); \\ \hline \hline
**Document-based MySQL: Update a single item, a single field operation** \\ \hline collection.modify(”_id = 00006080705500000000002713”) \\.set(”name”, “Nails by Ayana”).select(“address”, “London, United Kingdom, 4”).execute(); \\ \hline \hline \end{tabular}
\end{table}
Table 4: Update a single item and a single field operation.  
\begin{table}
\begin{tabular}{r} \hline \hline
**Relational MySQL: Update a Single Item but Multiple Fields Operation** \\ \hline @Query(value = “update business set name = name, address = address \\ where id = businessId, nativeQuery = true) \\ void updateMultipleFieldsBylId(@Param(“name”) String name, \\ @Param(“businessId”) long businessId, @Param(“address”) String address); \\ \hline \hline
**Document-based MySQL: Update a single item, multiple fields operation** \\ \hline collection.modify(”_id = 000060807055000000000002713”) \\.set(”name”, “Nails by Ayana”).set(“address”, “London, United Kingdom, 4”).execute(); \\ \hline \hline \end{tabular}
\end{table}
Table 5: Update a single item but multiple fields operation.