## 4 Performance Tests
### SELECT Operation
#### 4.3.2 Simple SELECT with Single Inner Join  
A simple select with a single inner join that returns all countries from Europe is presented in Table 5.  
In the case of this simple selection, the search in the CouchDB database is much faster than the relational MySQL but almost 50% slower than the document-based MySQL. In the case of using relational MySQL, response times are larger because it scans the entire table until it finds the item.  
#### 4.3.2 Simple SELECT with Single Inner Join  
A simple select with a single inner join that returns all countries from Europe is presented in Table 5.  
**COUCHDB****STR STRUCTURE:****Select with single inner join operation**  
_Send a request to get the continent id using requestBody: \"[(]\"selector\":[]\"name\":[]\"Europe(\")]\" parse the response using first structure of ResponseDTO; Send a second request to get all the documents with this continent id, requestBody: \"[(]\"selector\":[]\"continent_id\":\" + continentId + \")]\" ResponseDTO responseDTO = new ObjectMapper().readValue(string, ResponseDTO.class); Map<String, String> countries = responseDTO.getDocs();_  
**COUCHDB****SECOND****STRUCTURE:****Select with single inner join operation**  
_Send a request to get the continent id using requestBody: \"[(]\"selector\":[]\"name\":[]\"Europe(\")]\" parse the response using first structure of ResponseDTO; Send a second request to get all the documents with this continent id, requestBody: \"[(]\"selector\":[]\"continent_id\":\" + continentId + \")]\" ResponseDTO responseDTO = new ObjectMapper().readValue(string, ResponseDTO.class);_  
_List<Country> countries = responseDTO.getDocs().stream().map(Continent:getCountry).filter(doc> doc.getCity)== null).collect(toList());_  
Figure 7: Performance time (ms) for the simple select operation.  
\begin{table}
\begin{tabular}{l} \hline \hline
**RELATIONAL****MYSQL:****Select with single inner join operation** \\ \hline @Query(value = “select c.” from continent con inner join country c on con.id=c.continent_id \\ where con.name =:name”, nativeQuery = true) \\ List<Country> getByContinentName(@Param(“name”) String name); \\ List<Country> countries = countryRepository.getByContinentName(“Europe”); \\ \hline
**DOCOUNTENT-BASED****MYSQL:****Select with single inner join operation** \\ \hline DocResult res = collection.find(”name = “Europe” and country.name is not null”).execute(); \\ \hline \hline \end{tabular}
\end{table}
Table 5: Select with single inner join operations.  
Using the first structure, the search is done by the fields contained in a document. In this case, the reference to a document is done by _id_, thus we cannot search by the fields of that document, only by its _id_. Therefore, the first time searching by the document that has that name is done, and then look for all the countries that have this _continent_id_. Consequently, response times were automatically longer.  
Using the second structure, the selection is made through a single request in which all the documents from the continent of Europe were obtained. The next step was to interpret the answer and extract them. If only the countries were needed, all the documents that do not have a city were taken and finally, a list of all the countries was obtained. The command used for document-based MySQL is found for which we give as a parameter the search condition. The resulted response times differ greatly between MySQL and CouchDB, as shown in Figure 8, but there may be situations where the request may fail for various reasons (e.g., TimeoutException, Connection refused), and if we have dealt with this case by retrieving it several times, the times for CouchDB will increase automatically.  
In this case, when a small number of elements were involved, relational MySQL has better or similar performance (up to 10,000); the chosen structure for CouchDB influences performance only when large numbers of elements are involved, but the document-based MySQL has the best response times regardless of the number of elements.