Performance on node/add with thousands of groups

marcp - December 4, 2008 - 22:58
Project:OG Vocabulary
Version:HEAD
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

We've got a site that has 1,500 groups - each with its own vocabulary. The vocabularies are all single-level with 5 to 10 terms in each one.

When adding a node, core taxonomy's hook_form_alter() makes 2 sql calls per vocabulary to create all the taxonomy select boxes. Then, og_vocab's hook_form_alter() comes in and removes the 1,499 select boxes that don't pertain.

I'm just wondering if anyone else has come up with a solution for this... I'd rather not hack taxonomy.module (or og_vocab), but am considering it on this site because we are only using taxonomy for this one particular content type. The hack would be to remove taxonomy's hook_form_alter() and modify og_vocab's to add in just the one select box.

Anyone else done this before?

Thoughts on modifying core taxonomy to allow for other module(s) to handle the adding of taxonomy select boxes to node forms? Maybe a hook_taxonomy() call within taxonomy_form_alter() to allow for other modules to tweak the vocabulary-selecting SQL:

<?php
function taxonomy_form_alter($form_id, &$form) {
  if (isset(
$form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
   
$node = $form['#node'];

    if (!isset(
$node->taxonomy)) {
      if (
$node->nid) {
       
$terms = taxonomy_node_get_terms($node->nid);
      }
      else {
       
$terms = array();
      }
    }
    else {
     
$terms = $node->taxonomy;
    }

   
$c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);

    while (
$vocabulary = db_fetch_object($c)) {
     
// Here's where select boxes or textfields for tags get created for each vocabulary...
      // ...
   
}
  }
}

?>

Or modifying taxonomy_node_get_terms() to take a node instead of nid and doing some magic in there to catch the og_vocab case...

#1

alb - December 9, 2008 - 18:22

small question:
vocabularies are visible for all anonymous/groups or every group can see only the own vocabulary?

#2

Amitaibu - January 22, 2009 - 13:04
Status:active» postponed (maintainer needs more info)

I've just seen this module (haven't tested) - maybe it can help you
http://drupal.org/project/lowername

#3

marcp - March 25, 2009 - 17:14

I'm getting ready to remove og_vocab from the site mentioned above. At some point I'll revisit this issue, but wanted to get it back on the radar.

Another possible way to reduce the pain of og_vocab's method of pruning out all vocabs that don't pertain to a node being posted into a group would be for taxonomy to just go ahead and load all vocabularies for the given node type in one fell swoop. That's obviously a core taxonomy feature request, so perhaps this issue should be moved there.

It looks like the place to add this functionality would be in taxonomy_get_tree() -- possibly changing the $vid parameter to be an array of vids, which would preload the cache so that future taxonomy_get_tree() calls would return cached data for an individual vid. Ideally the SQL would change such that it would only take 1 call to load up, say 1500, vocabularies.

#4

minesota - March 25, 2009 - 17:13

SUBSCRIBED

 
 

Drupal is a registered trademark of Dries Buytaert.