Tema: ilgas sql
Autorius: tobias
Data: 2009-02-04 15:30:11
kaip optimizuoti mysql query - jei jis vykdomas 40 sekundziu!
jokiu fokusu nedarau
paselektinu straipnio id, headline,
is komentaru lenteles suskaiciuoju komentaru skaiciu

aciu uz komentarus


     SELECT articles.id,
     articles.title,
     articles.date,
     DATE_FORMAT(date,'%m/%d, %Y') as ArticleDate,
     articles.selected_foto,
     articles.foto_1,
     articles.foto_source,
     REPLACE(articles.source, ',', ' ') as source,
     LEFT(articles.article,350) as article_intro,
     COUNT(comments.id) as artComments
     FROM articles
     LEFT JOIN comments ON articles.id = comments.object_id
     WHERE articles.active  = '1'
     AND articles.category  = '21'
     GROUP BY articles.id
     ORDER BY articles.id
     DESC
     LIMIT 5