July 6, 2017

Performance improvement

The .search() method is quite useful to understand what you have on the model, but the response time can increase really fast! Imagine if you need to perform multiples searches? But there is a better way: use " (quotes) on your search string. On the image below, we can see how the performance increased by 4! Sure, with quotes it will search for the entire string only, but that might be the case, right? This sample is also restricting the search to "Name" attribute, as per last parameter (an array)

.search method performance

Depending on how big the model is and how many spaces you have on the search string, this difference can be from a couple seconds (with quotes) to a few minutes (without quotes)! 

As you can see on the image, you can run code on the browser console! This is quite useful for quit testing. 

Related Posts