Created
December 6, 2012 01:13
-
-
Save itsecureadmin/4221086 to your computer and use it in GitHub Desktop.
mysql exlain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXPLAIN | |
SELECT `devices`.`id` AS `id`, `serial_numbers`.`serial` AS `serial_number`, `mac_address`, | |
CAST(group_concat(CASE WHEN lookup_metrics.ui_metric_name = 'version_firmware_dsp' | |
THEN inverter_properties.property_value | |
ELSE null END) AS decimal(30,2)) AS `version_firmware_dsp`, | |
CAST(group_concat(CASE WHEN lookup_metrics.ui_metric_name = 'version_firmware_pvm' | |
THEN inverter_properties.property_value ELSE null END) AS decimal(30,2)) AS `version_firmware_pvm`, | |
CAST(group_concat(CASE WHEN lookup_metrics.ui_metric_name = 'pvm_status' | |
THEN inverter_properties.property_value | |
ELSE null END) AS decimal(30,2)) AS `pvm_status`, | |
`model_name`, `inverter_connection_history`.`state` AS `location_state`, `first_reported`, `last_reported`, | |
group_concat(DISTINCT inverter_lookup_status.name ORDER BY inverter_lookup_status.type SEPARATOR ',') AS `status`, | |
`inverter_monitor_polls`.`total_kwh`, | |
`inverter_monitor_polls`.`power_ac`, `inverter_monitor_polls`.`power_dc`, | |
`inverter_tripped_fault_list`.`fault_name_list` AS `current_faults` FROM `devices` | |
LEFT JOIN `serial_numbers` ON (`devices`.`id` = `serial_numbers`.`device_id`) | |
LEFT JOIN `inverter_properties` ON ((`devices`.`id` = `inverter_properties`.`inverter_id`) | |
AND (`inverter_properties`.`active` = 1)) | |
LEFT JOIN `lookup_metrics` ON (`lookup_metrics`.`id` = `inverter_properties`.`inverter_property_name_id`) | |
LEFT JOIN `lookup_models` ON (`devices`.`model_id` = `lookup_models`.`id`) | |
LEFT JOIN `inverter_connection_history` ON ((`devices`.`id` = `inverter_connection_history`.`inverter_id`) | |
AND (`inverter_connection_history`.`active` = 1)) | |
LEFT JOIN inverter_status_history | |
FORCE INDEX (active) ON devices.id = inverter_status_history.inverter_id AND inverter_status_history.active = 1 | |
LEFT JOIN `inverter_lookup_status` ON (`inverter_status_history`.`status_id` = `inverter_lookup_status`.`id`) | |
LEFT JOIN `inverter_monitor_polls` ON (`devices`.`last_poll_id` = `inverter_monitor_polls`.`id`) | |
LEFT JOIN `inverter_tripped_fault_list` ON ((`inverter_monitor_polls`.`fault_asserted` = 1) | |
AND (`devices`.`last_poll_id` = `inverter_tripped_fault_list`.`inverter_poll_id`)) | |
WHERE ((`devices`.`device_type_id` IN (2)) AND (`last_reported` IS NOT NULL)) GROUP BY `devices`.`id` | |
ORDER BY `last_reported` | |
DESC | |
; | |
+----+-------------+-----------------------------+--------+--------------------------------------------------+------------------+---------+----------------------------------------------------------+------+----------------------------------------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+----+-------------+-----------------------------+--------+--------------------------------------------------+------------------+---------+----------------------------------------------------------+------+----------------------------------------------+ | |
| 1 | SIMPLE | devices | index | NULL | PRIMARY | 4 | NULL | 4962 | Using where; Using temporary; Using filesort | | |
| 1 | SIMPLE | serial_numbers | ref | device_id | device_id | 4 | device_hub.devices.id | 1 | | | |
| 1 | SIMPLE | inverter_properties | ref | device_id,device_active_tdx | device_id | 4 | device_hub.devices.id | 2 | | | |
| 1 | SIMPLE | lookup_metrics | eq_ref | PRIMARY | PRIMARY | 4 | device_hub.inverter_properties.inverter_property_name_id | 1 | | | |
| 1 | SIMPLE | lookup_models | eq_ref | PRIMARY | PRIMARY | 4 | device_hub.devices.model_id | 1 | | | |
| 1 | SIMPLE | inverter_connection_history | ref | fk_inverter_connection_history_inverters1,active | active | 6 | const,device_hub.devices.id | 42 | | | |
| 1 | SIMPLE | inverter_status_history | ref | active | active | 6 | device_hub.devices.id,const | 990 | | | |
| 1 | SIMPLE | inverter_lookup_status | ref | PRIMARY | PRIMARY | 4 | device_hub.inverter_status_history.status_id | 1 | | | |
| 1 | SIMPLE | inverter_monitor_polls | eq_ref | id | id | 8 | device_hub.devices.last_poll_id | 1 | | | |
| 1 | SIMPLE | inverter_tripped_fault_list | ref | inverter_poll_id | inverter_poll_id | 4 | device_hub.devices.last_poll_id | 1 | | | |
+----+-------------+-----------------------------+--------+--------------------------------------------------+------------------+---------+----------------------------------------------------------+------+----------------------------------------------+ | |
10 rows in set (0.03 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment