Hi community
I have this problem
I have a node block view with exposed filters. I have also a taxonomy vocabulary with many terms (over 2000) and in in the nodes i have a reference field for this taxonomy terms. Ok until here everything is ok. When i search under the filter criteria of the views for a specific term oder for all terms or something else, i have this results:
Query build time: 13.58 ms
Query execute time: 0.69 ms
View render time: 2.62 ms
And here the query:
SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, node.created AS node_created, 'node' AS field_data_field_summary_node_entity_type
FROM
{node} node
INNER JOIN {field_data_field_initiative_location} field_data_field_initiative_location ON node.nid = field_data_field_initiative_location.entity_id AND (field_data_field_initiative_location.entity_type = 'node' AND field_data_field_initiative_location.deleted = '0')
INNER JOIN {taxonomy_index} taxonomy_index ON node.nid = taxonomy_index.nid
WHERE (( (node.status = '1') AND (node.type IN ('initiative')) AND (node.language IN ('en', 'und')) AND (field_data_field_initiative_location.field_initiative_location_tid = '37') AND (taxonomy_index.tid IN ('11995', '11997', '11996')) ))
ORDER BY node_created DESC
LIMIT 20 OFFSET
Thats ok. BUT when i set the filter criteria of the taxonomy term reference to exposed, I get these results:
Query build time: 4869.64 ms
Query execute time: 0.93 ms
View render time: 3.69 ms
And this query:
SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, node.created AS node_created, 'node' AS field_data_field_summary_node_entity_type
FROM
{node} node
INNER JOIN {taxonomy_index} taxonomy_index ON node.nid = taxonomy_index.nid
WHERE (( (node.status = '1') AND (node.type IN ('initiative')) AND (node.language IN ('en', 'und')) AND (taxonomy_index.tid IN ('11995', '11997', '11996')) ))
ORDER BY node_created DESC
LIMIT 20 OFFSET 0
My question
Why is the query build time so much longer when i set the filter to exposed? In the node form i have also this taxonomy term reference field and and there it loads much faster.
Comments
Query Tuning
What database are you running? It sounds like you need to do a couple of things. If you're running postgresql, make sure that you vacuum the database periodically. Start with monthly and dial it back from there. If you're running MySQL, see if you can bump up the memory in my.cnf. You also need to create some indexes in the database to speed up the queries. If you're not comfortable with this, there are tools out there like Idera.com's SQL Doctor that can help you tune a SQL query.
Hello recentcoin
Hello recentcoin
Thanks for your reply. I have MySQL. But can you explain me exactly why the view loads so slow? The second (problem-) query is superfast in the execution. But Views build the query very slow, i don't understand why. Because the same taxonomy field loads in the node form with normal speed. Why not in the exposed filter?
Ok, I had turned on the devel module and the problem is DrupalDatabaseCache and metatag_metatags_load_multiple (see the screenshots).
I also turned off the views cache in views settings but the same results... Is there a solution für this??
EDIT:
Oh i can't upload screenshot in this post... Then i must do this:
ms: 114.07
where: DrupalDatabaseCache::getMultiple
ops: PAO
ms: 23.09
Where: DrupalDatabaseCache:set
ops: PA
ms: 17.55
Where: metatag_metatags_load_multiple
ops: PAO
ms: 9.27
Where: DrupalDefaultEntityController::load
ops: PAO
ms: 5.27
Where: node_tag_new
ops: PA
And i find another
And i find another interessting thing. i have a old backup and there it is work correctly, but i can't use this old backup...
But in the same view, the view query use:
The interessting part ist the INNER JOIN part:
My second (problem-) query in my first post NOT use this INNER JOIN... hm... but the views configuration is the same... How can tell views to use the taxonomy index?
EDIT:
Ok now i have the same query with the inner join taxonomy index, but it has also a long build time.
****!!! I HAVE FOUND THE
****!!! I HAVE FOUND THE PROBLEM!! IT is the Views-Update from 3.7 to 3.8!!! Oh man... i report this immediately!
https://drupal.org/node/2277811