While working on one of my Drupal projects performance optimization and queries profiling I found several groups of queries that looks like:

SELECT * FROM term_data WHERE tid IN (tid1, tid2, tid3)
SELECT * FROM term_data WHERE tid IN (tid1)
SELECT * FROM term_data WHERE tid IN (tid2)
SELECT * FROM term_data WHERE tid IN (tid3)

As you can see there were N+1 queries that verified N terms, and single SELECT queries always followed by SELECT query that includes all single.

After I applied my patch, that implements caching for validation results, single queries disappeared and I got 315 queries instead of 609 for view I tested on and page generation time decreased for almost 50%.

CommentFileSizeAuthor
views-validate-term-cache.patch1.89 KBvgarvardt

Comments

ajayg’s picture

Do you have the simple view exported? SO It will give an idea what type of views will benefit most.

vgarvardt’s picture

It affects default taxonomy_term view, bundled with Views module, on term pages that include all child terms.

merlinofchaos’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Committed to 2.x and 3.x -- needs to be ported to 7.x-3.x as it does not apply.

vgarvardt’s picture

I'm not this is possible with current D7 Views state.

I installed Taxonomy in D7, added field, generated taxonomy terms, nodes, tested with taxonomy/term/1 and got list with 1 node. Then I installed views 7.x-3.x-dev from October 20, 2009 (latest version I found in releases), enabled taxonomy_term view, tried taxonomy/term/1 and got "Page not found", Views debug message

Status message
Debug: 'Views data build time: 1.41191482544 ms' in _views_fetch_data() (line 49 of /home/vladimirga/www/devel7/sites/all/modules/contrib/views/includes/cache.inc).

and PHP notice

Error message
Notice: Undefined property: views_plugin_argument_validate_taxonomy_term::$value in views_plugin_argument_validate_taxonomy_term->validate_argument() (line 83 of /home/vladimirga/www/devel7/sites/all/modules/contrib/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc).

Should I use CVS version of Views for D7? If yes - please give me the url.

Or it would be better to create separate issue for this?

merlinofchaos’s picture

Yeah, taxonomy in D7 has changed a lot -- I think it may not be possible until the field integration is complete. See http://drupal.org/node/626704

vgarvardt’s picture

Will subscribe to #626704: Build views integration for field.module so when it will be fixed I'll port my patch for D7 Views.

dawehner’s picture

Status: Patch (to be ported) » Fixed

Even if the taxonomy integration is different this table still exists.

Ported and commited the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.