Working on applications with a lot of data and thousands of users it means that we always need to be with an eye on performance. We often hear questions like "Why this save takes so long?" or "Why your request is faster than mine" and so on. So we put together a list of tips& tricks / best practices that will always help you keep your performance under control.
The default value for this property is true, which means that String parameters are send to the database in Unicode format (for example it will send VARCHAR parameter in NVARCHAR, so there will be an extra/implicit conversion).If we set this value to false, the String parameters will be sent to the database in non-Unicode format. Below we have an example of a query run with the parameter set to true and then the same query with the parameter set to false.
Caching helps to avoid reading the same data multiple times, so the time used for that reading will decrease considerably, especially if we have a lot of data. But it is important to apply this concept to data that does not change very often, because otherwise the new changes on those data will not be taken into account, the old version being saved in the cache.
For 44k rows, we can see that the time has decreased from 21 seconds to 23 milliseconds using caching, so this is an important instrument in controlling the performance of an application.
Implementing business logic in SQL is probably not the first thought that comes to mind for a developer. Many are accustomed to keeping the database just to store information and all the logic to be done in Java. But there are situations where a logic written in SQL saves more time, the database being very efficient in working with a lot of heavy data. The best way we can do this is through stored procedures called from Java or through native queries.
Asynchronous methods help a lot in reducing execution time, but must be used intelligently, not in situations where these methods update the data used immediately in the application. For example, we may use asynchronous methods when we want to send notifications/emails to users to let them know that their data processing is complete. Sending the email may take some time, so there is no need for the application to wait for the email to be sent to display the end of the operation in the UI.
This also helps if the asynchronous method fails, so that the user does not feel this in the application and can continue to work
Here are some simple examples of how we can improve the performance of an application, things we may or may not have thought about, but which, with a few changes, help keep a large application under control.