Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-7270

Add a delay for ajax search boxes

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.3.1
    • Fix Version/s: Unscheduled
    • Component/s: Usability
    • Labels:
      None

      Description

      If the user quickly types 'Smith' in the search box to find a contact, the browser does 5 queries, each taking nearly 3.8s on a local machine (as seen in screenshot). Only one query should be necessary.

      If the query script fires after a timer of lets say, 200ms, this would result in only one search after typing 'Smith', provided the user typed each key within 200ms of each other. The timer to trigger the re-query would be reset to 200ms every time the user typed a key.

      A side-effect of this is if you type "smith", then press backspace, then change it to "smalls", all really fast, it takes several seconds to get all the way to "smalls". This results in many unnecessary queries and wasted time waiting, which would be eliminated if the search script fired after a short timer.

      When there is only one query, E.g. 'A', the query takes less than 1.4s, a 63% performance increase.

      This could/should be implemented on all search fields: the one at the top of the screen, the lookup field for the employer, the 'share address with...' lookup field, etc.

      Separate from this bug...
      It would be useful to investigate how long it takes to query a large subset of the database and return the entire result set, instead of limiting it to 10 results. Then a javascript could filter the dataset locally, instead of re-querying the server each time.

      For example, let's say the user types "sm". CiviCRM would send the query for either "LIKE s%" or "LIKE sm%" depending on the number of contacts in the database and return all of the records. If the user proceeded to type "ith" (for "smith"), the browser would filter this list on the local machine, without the need to requery the list. The only time the list would be re-queried is if the user changed from "smith" to "jones" (a different starting letter).

      Separate from that:
      Are the contacts lists cached for the quick search? If not, do you think caching them, and updating the cache every time a user is added/updated/deleted, this would result in a performance increase?

      Note: Facebook loads all of your friends as soon as you click on the search field, and filters the results using javascript. A facebook friends list is a considerably smaller results set, but I thought it was useful to mention, because Facebook's results appear very responsive to the user.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              caseye Casey
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: