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 `hotel_rate_detail` ADD INDEX `hotel_detail_idx_hotels_id` (`hotels_id`);
ALTER TABLE `hotel_week_days` ADD INDEX `hotel_days_idx_h_id` (`h_id`);
ALTER TABLE `hotels_list` ADD INDEX `hotels_list_idx_hotel_city_hotel_id_hotel_star` (`hotel_city`,`hotel_id`,`hotel_star`);
ALTER TABLE `hotels_list` ADD INDEX `hotels_list_idx_hotel_id` (`hotel_id`);
SELECT
h.hotel_id AS id,
h.hotel_city AS city,
h.hotel_name AS hotelname,
h.hotel_star AS hotelcat,
hwd.double_spl_rate,
hwd.extra_bed_spl_rate,
hwd.meal_plan_spl,
hwd.third_party_rate,
hwd.third_party_extra_bed,
hwd.third_party_meal_plan,
hwd.room_category,
hrd.hotel_rate_from,
hrd.hotel_rate_to
FROM
hotels_list AS h
INNER JOIN
hotel_rate_detail AS hrd
ON h.hotel_id = hrd.hotels_id
INNER JOIN
hotel_week_days AS hwd
ON hrd.hotel_id = hwd.h_id
WHERE
(
(
'2015-07-02' BETWEEN hrd.hotel_rate_from AND hrd.hotel_rate_to
)
OR (
'2015-07-03' BETWEEN hrd.hotel_rate_from AND hrd.hotel_rate_to
)
)
AND (
h.hotel_city = '1'
)
AND (
hwd.double_spl_rate != 0
OR hwd.third_party_rate != 0
)
AND (
h.hotel_star <= '2'
)
AND h.hotel_id = 364
GROUP BY
h.hotel_id
ORDER BY
hwd.double_spl_rate,
hwd.third_party_rate ASC