SELECT node.nid AS nid,
DATE_FORMAT(FROM_UNIXTIME(node.created), '%Y%m%d%H') AS node_created_hour,
'taxonomy_term:feed' AS view_name
FROM node node
WHERE (node.status = 1 OR (node.uid = 0 AND 0 <> 0) OR 0 = 1) AND (node.vid IN (
SELECT tn.vid FROM term_node tn
WHERE tn.tid = 370101
))
ORDER BY node_created_hour DESC
LIMIT 0, 15\G
任何想法或建议如何让这个视图更快地运行?
答案 0 :(得分:0)
而不是
AND (node.vid IN (
SELECT tn.vid FROM term_node tn
WHERE tn.tid = 370101
))
这样的事情应该有效:
SELECT node.nid AS nid,
DATE_FORMAT(FROM_UNIXTIME(node.created), '%Y%m%d%H') AS node_created_hour,
'taxonomy_term:feed' AS view_name
FROM node node
INNER JOIN term_node tn on tn.vid = node.vid
WHERE (node.status = 1 OR (node.uid = 0 AND 0 <> 0) OR 0 = 1) and tn.tid = 370101
ORDER BY node_created_hour DESC
LIMIT 0, 15\G