In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `data` ADD INDEX `data_idx_access_fk` (`access_point_id_name_fk`);
ALTER TABLE `meta` ADD INDEX `meta_idx_sensor_name_id` (`sensor_name`,`id`);
ALTER TABLE `prop` ADD INDEX `prop_idx_proid` (`proid`);
ALTER TABLE `string` ADD INDEX `string_idx_access_value_timebase` (`access_point_id_value`,`timebase`);
SELECT
esm1.prop_id,
epc.propertyname,
esm1.thermostat_id,
esm1.thermostat_name,
count(esm1.thermostat_id) * 5 AS minutes
FROM
meta esm1
INNER JOIN
data AS esdn
ON esm1.id = esdn.access_point_id_name_fk
INNER JOIN
prop AS epc
ON epc.proid = esm1.prop_id
INNER JOIN
(
SELECT
(esds.timebase) AS tb,
(esm2.thermostat_id) AS tid
FROM
string esds
INNER JOIN
meta esm2
ON esds.access_point_id_name_fk = esm2.id
WHERE
esm2.sensor_name = 'zoneClimate'
AND esds.access_point_id_value = 'Occupied'
AND esds.timebase >= '60960'
AND esds.timebase <= '60986'
) AS esds_tmp
ON esds_tmp.tb = esdn.timebase
AND esds_tmp.tid = esm1.thermostat_id