All pastes #978585 Raw Edit

Something

public text v1 · immutable
·published 2008-04-09 17:56 UTC
rendered paste body
mysql> explain SELECT DISTINCT
    ->                                         r.id
    ->                                         , r.user_id
    ->                                         , r.text
    ->                                         , r.date_added
    ->                                         , r.date_modified
    ->
    ->                                         , u.username AS user_nick
    ->                                         , u.date_signup AS user_signup_date
    ->                                         , i.gender AS user_gender
    ->                                         , CONCAT_WS( ' ', i.firstname, i.surname ) AS user_name
    ->                                         , i.title AS user_title
    ->                                         , o.user_id IS NOT NULL AS user_is_online
    ->                                         , IFNULL( p.has_avatar, 0 ) AS user_has_avatar
    ->                                         , c.postCount
    ->                                 FROM forum_reply AS r
    ->                                         LEFT JOIN user AS u ON ( r.user_id = u.user_id )
    ->                                         LEFT JOIN forum_user_postcount AS c ON r.user_id = c.userId
    ->                                         LEFT JOIN user_info AS i ON ( r.user_id = i.user_id )
    ->                                         LEFT JOIN user_session AS o ON ( r.user_id = o.user_id AND o.updated >= DATE_SUB( NOW(), INTERVAL 5 MINUTE ) )
    ->                                         LEFT JOIN user_photo AS p ON ( r.user_id = p.user_id )
    ->                                 WHERE r.topic_id = 23113
    ->                                         AND r.date_deleted IS NULL
    ->                                 ORDER BY r.date_added DESC
                                LIMIT 20;
    ->                                 LIMIT 20;
+----+-------------+-------+--------+-------------------------------------------+----------+---------+---------------------------+------+----------------------------------------------+
| id | select_type | table | type   | possible_keys                             | key      | key_len | ref                       | rows | Extra                                        |
+----+-------------+-------+--------+-------------------------------------------+----------+---------+---------------------------+------+----------------------------------------------+
|  1 | SIMPLE      | r     | ref    | date_deleted,topic_id.date_added,topic_id | topic_id | 13      | const,const               | 3170 | Using where; Using temporary; Using filesort |
|  1 | SIMPLE      | u     | eq_ref | PRIMARY                                   | PRIMARY  | 3       | leidenonline_nu.r.user_id |    1 |                                              |
|  1 | SIMPLE      | c     | eq_ref | PRIMARY                                   | PRIMARY  | 3       | leidenonline_nu.r.user_id |    1 |                                              |
|  1 | SIMPLE      | i     | eq_ref | PRIMARY                                   | PRIMARY  | 3       | leidenonline_nu.r.user_id |    1 |                                              |
|  1 | SIMPLE      | o     | ref    | user_id,updated                           | user_id  | 3       | leidenonline_nu.r.user_id |    1 |                                              |
|  1 | SIMPLE      | p     | eq_ref | PRIMARY                                   | PRIMARY  | 3       | leidenonline_nu.r.user_id |    1 |                                              |
+----+-------------+-------+--------+-------------------------------------------+----------+---------+---------------------------+------+----------------------------------------------+

# User@Host: nucom_engine[nucom_engine] @  [192.168.2.7]
# Query_time: 4  Lock_time: 0  Rows_sent: 20  Rows_examined: 36729