drupaldrupal-viewsdrupal-taxonomy

Exposed filter in Views for Drupal 7 with taxonomy of 30k elements takes too long


I'm exposing a Taxonomy filter on my view in Drupal 7 with 30k elements on 4 levels of hierarchical, and it takes the page something like 4-7 minutes in order to load.

I expose them as a list with hierarchy, so I've tried with hook_form_alter to hide taxonomy elements with no node associated by unsetting them, but it's useless because i don't want them to load at the beginning.

So I tried both "Hierarchical Select" and "Simple hierarchical select" by using the filter but still 4-7 minutes in order to load the page, because it loads anyway all the elements in the form array.

Just for my curiosity, I've printed with php the entire vocabulary (no Drupal functions) and it takes like 5 seconds, why Drupal is so slow doing this?

My searches about another hook able to not load unwanted options did not bring me anything, what else can I try?


Solution

  • I've found a solution: i've exposed the filter as an autocomplete and, in order to differenziate the levels, i overridded the default page for the response in hook_menu

    First, unset the default page unset($items['admin/views/ajax/autocomplete/taxonomy/%/%']);

    then re created with my custom function, where returns a json with value-key with my custom labels