Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have noticed, that every time comment is being loaded _vud_comment_get_node_type is being called to get node type performing SQL query. If you have 50 comments per page, that's 50 queries, if 300?
I suggest usging static cache as follows in vud_comment.module
/**
* Function to return the node type of a particular node ID.
*/
function _vud_comment_get_node_type($nid) {
static $cache = array();
if (!isset($cache[$nid])) {
$type = db_result(db_query("SELECT type from {node} where nid = %d", $nid));
$cache[$nid] = $type;
return $type;
}
else {
return $cache[$nid];
}
}
6.x-2.x has the same problem.
Comment | File | Size | Author |
---|---|---|---|
#1 | 0001-Issue-1407042-by-Ainur-marvil07-Fixed-Multiple-calls.patch | 1.05 KB | marvil07 |
Comments
Comment #1
marvil07 CreditAttribution: marvil07 commentedOMG, that was bad :-/
I changed a little the code, as the patch attached, and pushed it to 6.x-3.x.
Thanks!
Comment #2
Ainur CreditAttribution: Ainur commentedThanks for the patch. Already using since January.
Comment #4
mgzrobles CreditAttribution: mgzrobles commentedsame for 7.x version