Skip to content

Instantly share code, notes, and snippets.

@hugowetterberg
Created May 19, 2010 13:37
Show Gist options
  • Save hugowetterberg/406315 to your computer and use it in GitHub Desktop.
Save hugowetterberg/406315 to your computer and use it in GitHub Desktop.
# Given a table term_article_count(tid, node_count)
# the following could be executed to refresh a node count cache.
TRUNCATE term_article_count;
INSERT INTO term_article_count(tid, node_count)
SELECT tn.tid, COUNT(n.nid)
FROM term_node AS tn
INNER JOIN node AS n ON (tn.vid=n.vid AND n.type='location' AND n.status=1)
GROUP BY tn.tid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment