## 4 Performance Tests
### Select Statement
#### 4.2.4 Complex Select Statement with Four Search Criteria  
In the selection operation applying four search criteria, ten ads with cars for sale will be extracted that have the make, model, price, and year of registration according to the conditions selected in the search form. A more complex select statement that uses four search criteria is presented in Table 5, and the obtained performance results are described in Figure 11.  
Based on the results obtained from the selection operations presented above, it can be seen that both Elasticsearch and MySQL Document Store are very fast in the data search  
Figure 11: Complex select statement with four search criteria. \begin{table}
\begin{tabular}{c c} \hline \hline
**MySQL Document Store** & _schema.getCollection(CARS),find(\"carMake = ’Audi’ and carModel = ’A4’ and price \textgreater{}= 6000 and price \textless{}= 15,000 and firstRegistrationYear \textgreater{}= ’2009’ and firstRegistrationYear \textless{}= ’2013”),sort(\"id\"), limit(10).execute();_ \\ \hline
**Elasticsearch** & _( _ “size”-10,_ _ “query”:_[_ \\  & _ “body”:_[_ \\  & _ “must”:_[_ \\  & _[_”match”:_[_ \\  & _[_”match”:_[_ \\  & _[_”match”:_[_ \\  & _[_”range”:_[_ \\  & _”from”:_”600”,_\"to\":_[_ \\  
process. Response times are relatively close, but in some cases Elasticsearch has higher response times than MySQL Document Store. Performing an analysis of the response times according to the number of criteria applied in the search process, it can be seen that those for MySQL Document Store are kept constant without having a significant increase when applying several criteria. This statement is also valid for Elasticsearch, but in the selection operation with four search criteria there was an increase in response times until there were 100,000 documents. Starting from 500,000 documents, the times obtained have a better response time compared to previous selection operations. This decrease in response times can be caused by the fact that Elasticsearch assigns a higher score to documents that are returned for various search criteria. A bool query will combine the scores obtained for all queries to return the documents that best match the search criteria. Considering that the time differences are at the level of milliseconds, and the times obtained in the data selection process are very good, it can be stated that both were very fast in the data selection process and are very good alternatives for searching data, bringing a major benefit to performance. Another important aspect is not only the fact that the response times were not influenced by the increase of the number of documents, but also the fact that the time differences between the time when 30,000 documents and 2,000,000 documents were stored are very small. An important detail is also that sorting in MySQL Document Store is performed on a field with the index associated. Thus, to further highlight the importance of an index, Figure 12 shows the search times obtained by the MySQL Document Store on a field without an associated index, according to the statements from Table 6.  
Making a comparison between the times obtained in Figure 10, where also two searching criteria were used, a huge difference between the times obtained in the two cases can be seen. To avoid these very long processing times, when using MySQL Document Store it is very important to create indexes for the fields that will be used in the data search process. Based on this, Elasticsearch has another advantage due to the fact that it is not necessary to create indexes for the fields used in the document because each document structure that describes one or more tables in a relational database represents an index. Figure 12: Select statement with two search criteria without index on MySQL Document Store. Based on the results obtained, it can be stated that an index is essential when using MySQL Document Store. The time differences are major in this case because MySQL Document Store has to go through all the documents one by one to check if they meet the selection condition.