0

I have an exposed auto-complete taxonomy filter, It takes time(2sec) to load the values. How to increase the performance to load the values quickly and I'm using views 2.x.

5
2

Assuming a Drupal installation configured for a production environment (including Apache and MySQL tuning), there are two things that impact autocomplete latency.

One, is a built-in delay between user input and running searches. This is baked into misc/autocomplete.js. The value is set to 300ms (line 245), and get used in Drupal.ACDB.prototype.search (line 287).

The second is that searches will run on a single character. If your autocomplete result set is large, this can have huge performance impacts.

Unfortunately, there isn't a good way to alter either of these behaviors. You can add your own Javascript and redeclare Drupal.ACDB to use a shorter delay, eg

Drupal.ACDB = function (uri) {
  this.uri = uri;
  this.delay = 100;
  this.cache = {};
};

and Drupal.ACDB.prototype.search to add in some logic to enforce a minimum number of characters, eg

...
// See if this string needs to be searched for anyway.
searchString = searchString.replace(/^\s+|\s+$/, '');
if (searchString.length <= min ||
  searchString.charAt(searchString.length - 1) == ',') {
  return;
}
...

However, 400 results isn't a huge number. I have mainly seen the delays this with 10000+ results. This suggests that you may need to do some additional profiling on your server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.