Recently, I had a problem about slow queries. Table index was a first cause of slow queries; however, the problem was still exists after adding the indexing. Using SQL Server Profiler to trace the queries, there was some queries seem like confused. The column was Varchar but the query use Nvarchar. Therefore, the query didn’t use the indexing so the query became very slow.
After googling and talking to my colleague, we found a method of JDBC DataSource which was “setSendStringParametersAsUnicode“. This method convert Varchar to NVarchar so the indexing was not used.
As a result, this parameter was easy to forget when you were using the Varchar type which was used as a condition.