Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-4563

PatientSearchCriteria: identifier "ignoreCase()" restriction adds significant search overhead

    XMLWordPrintable

    Details

    • Complexity:
      Low

      Description

      When preparing an identifier criteria using an exact match, the following code is used:

      if (matchIdentifierExactly) {
          conjuction.add(Restrictions.eq("ids.identifier", identifier).ignoreCase());
      }
      

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mogoodrich Mark Goodrich
              Reporter:
              mogoodrich Mark Goodrich
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: