Ido\StatusQuery: join ALL latest comment

And it was soooo fast :p

refs #7057
This commit is contained in:
Thomas Gelf 2014-09-02 15:31:06 +02:00
parent d8e71d3790
commit a58b2aac00
1 changed files with 4 additions and 3 deletions

View File

@ -515,9 +515,10 @@ class StatusQuery extends IdoQuery
$sub = '(SELECT'
. ' c.object_id,'
. " '[' || c.author_name || '] ' || c.comment_data AS $fieldName"
. ' FROM icinga_comments c'
. ' WHERE c.entry_type = ' . $entryType
. ' ORDER BY c.comment_id DESC LIMIT 1)';
. ' FROM icinga_comments c JOIN ('
. ' SELECT MAX(comment_id) AS comment_id, object_id FROM icinga_comments'
. ' WHERE entry_type = ' . $entryType . ' GROUP BY object_id'
. ' ) lc ON c.comment_id = lc.comment_id)';
return new Zend_Db_Expr($sub);
}