我正在开发一个酒店搜索引擎。对于每个日期,它都有类似hotel info
,的表格。hotel availability
它运行良好,但与其他酒店搜索引擎(如 easytobook 或 hotel.com)相比,结果很慢。我的问题是:我怎样才能让它更快?目前它使用PHP直接从数据库中获取结果。
这是用于从数据库中获取结果的当前查询
SELECT DISTINCT t_hotel_info.hotelid,
t_hotel_info.hotelname,
t_hotel_info.description,
t_hotel_info.userid,
t_hotel_info.starrating,
t_hotel_info.currency,
t_hotel_info.hotel_url,
t_hotel_info.address1,
t_hotel_info.state,
t_hotel_info.country,
t_hotel_images1.imagepath1
FROM t_hotel_info
INNER JOIN t_hotel_images1
ON t_hotel_info.userid = t_hotel_images1.userid
INNER JOIN t_hotel_availability
ON t_hotel_info.userid = t_hotel_availability.userid
INNER JOIN t_hotel_account_info
ON t_hotel_info.userid = t_hotel_account_info.userid
INNER JOIN t_hotel_facilities
ON t_hotel_info.userid = t_hotel_facilities.userid
WHERE city = '$_GET[city]'
AND t_hotel_availability.sdate >= '$_GET[checkin]'
AND t_hotel_availability.sdate < '$_GET[checkout]'
AND t_hotel_availability.roomrate <> 0
这是我对表格的解释声明
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t_hotel_facilities ALL NULL NULL NULL NULL 627 Using temporary
1 SIMPLE t_hotel_info ref PRIMARY PRIMARY 4 ezee2book.t_hotel_facilities.UserID 8 Using where
1 SIMPLE t_hotel_account_info ALL NULL NULL NULL NULL 767 Using where; Using join buffer
1 SIMPLE t_hotel_images1 ALL NULL NULL NULL NULL 732 Using where; Using join buffer
1 SIMPLE t_hotel_availability ALL NULL NULL NULL NULL 51806 Using where; Distinct; Using join buffer