SQL 语句优化

指尖上的程序员 2014-04-01 11:48:16
SELECT h.HotelId,h.hotelName ,h.hotelEnglishName,h.country,h.city,h.tow,h.Location,h.salableState,h.StarLevel,h.ProductLabel,h.HotelType,
ext.Address,ext.Rating,ext.Parking,ext.SwimmingPool,ext.Restaurant,ext.OtherFacility,ext.PickupService,ext.ForeignExchange,ext.NetworkService,
ext.OtherService,ext.AcceptCreditCard,ext.OtherPolicy,image.path as imgPath,MIN(p.Price) as Price FROM sz_hotel as h LEFT JOIN sz_exthotel as ext ON (ext.HotelId=h.HotelId)
LEFT JOIN sz_roomtype as r ON (r.HotelId=h.HotelId) LEFT JOIN sz_hotelpicture as image ON (image.HotelId=h.HotelId)
LEFT JOIN sz_DateRoomPriceInfo as p ON ( p.RoomId=r.RoomTypeId AND p.Price <>0 AND p.Price IS NOT NULL) group by h.HotelId
...全文
237 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
@benluobobo 多谢 快了很多很多
benluobo 2014-04-01
  • 打赏
  • 举报
回复
alter table sz_hotel add index ix_sz_hotel_HotelId(HotelId); alter table sz_roomtype add index ix_sz_roomtype_HotelId(HotelId); alter table sz_hotelpicture add index ix_sz_hotelpicture _HotelId(HotelId);
benluobo 2014-04-01
  • 打赏
  • 举报
回复
alter table sz_hotel add index ix_sz_hotel_HotelId(HotelId); alter table sz_roomtype add index ix_sz_roomtype_HotelId(HotelId); alter table sz_hotelpicture add index ix_sz_hotelpicture _HotelId(HotelId);
  • 打赏
  • 举报
回复
多谢高手:
benluobo 2014-04-01
  • 打赏
  • 举报
回复
用explain在select语句前面,贴出执行计划

56,940

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧