0

这是我第一次做这么大的查询和这么多的连接。当我执行此查询时,速度非常慢。我不知道如何使用外键,如果它甚至有帮助......但如果有人知道我可以加快速度的方法,那将非常有帮助。这是我的查询:

SELECT FLOOR(AVG(ra.double)) AS price, hi.hname,  hi.hotel_id as hid, hi.hstars, hi.haddress, im.image_file, hd.short_desc, pr.promo_name, pr.discount, pr.discount_type, pr.book_start, pr.book_end 
    FROM hotel_info AS hi 
    JOIN images AS im ON im.foreign_id = hi.hotel_id 
    LEFT JOIN hotel_desc AS hd ON hd.hotel_id = hi.hotel_id 
    RIGHT JOIN rates AS ra ON ra.hotel_id = hi.hotel_id 
    RIGHT JOIN promotions AS pr ON pr.hotel_id = ra.hotel_id 
    WHERE ra.booking_date  BETWEEN '2012-01-01' AND '2012-01-06' 
    AND ra.double != '0.00' 
    AND hi.status = '1' 
    AND hi.destination_id = '$destination' 
    GROUP BY hi.hotel_id
4

0 回答 0