Query EXPLAIN EXTENDED select sum(timestampdiff(second ,CH1.lastUpdate,CH2.lastUpdate)) as session_time, sum(( select count(eventType)from chataudit as CA1 where CA1.eventType = 'OP_MESSAGE' AND CA1.operator='testop2' and CA1.lastUpdate > CH1.lastUpdate and CA1.lastUpdate < CH2.lastUpdate )) as sent_message_count, sum(( select count(eventType) from chataudit as CA2 where CA2.eventType = 'MSG_Q_SERVED' AND CA2.operator='testop2' and CA2.lastUpdate > CH1.lastUpdate and CA2.lastUpdate < CH2.lastUpdate )) as recieved_message_count from chataudit as CH1 inner join chataudit as CH2 on CH1.eventType='OP_LOGIN' and CH2.eventType='OP_LOGOUT' and CH2.lastUpdate = (select min(INCH.lastUpdate) from chataudit as INCH where INCH.eventType='OP_LOGOUT' and INCH.lastUpdate>CH1.lastUpdate) where CH1.operator='norgeop23' and CH1.lastUpdate>'2011-01-19' and CH2.lastUpdate<'2011-01-21', Mon Jan 24 10:05:29 2011

idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra
1PRIMARYCH1refchataudit_event_type,chataudit_last_updatechataudit_event_type767const8970Using where
1PRIMARYCH2refchataudit_event_type,chataudit_last_updatechataudit_last_update8func1Using where
4DEPENDENT SUBQUERYINCHrefchataudit_event_type,chataudit_last_updatechataudit_event_type767const9622Using where
3DEPENDENT SUBQUERYCA2refchataudit_event_type,chataudit_last_updatechataudit_event_type767const649350Using where
2DEPENDENT SUBQUERYCA1refchataudit_event_type,chataudit_last_updatechataudit_event_type767const236192Using where