When preparing an identifier criteria using an exact match, the following code is used:
Looking at the underlying query generated by Hibernate, I'm seeing:
where lower(identifier.identifier) = '123ABC'
That is, the "ignoreCase()" option is causing a "lower" to be applied to the identifier column of the patient identifier table, thereby losing the benefit of the index on the identifier column.
When I remove the "ignoreCase()" and test against a production-sized database, doing an exact-match patient identifier lookup improves from taken 1-2 seconds to being almost instantaneous.
This ignoreCase() should also be irrelevant when using a case-insensitive mysql database.
We should not use the ignoreCase() restriction when Context.getAdministrationService().isDatabaseStringComparisonCaseSensitive() is false.