最近在工作中遇到一个查询 关联了11个表 执行很慢 请高手赐教 请问有什么优化方案没有

解决方案 »

  1.   

    贴出你的查询语句和索引情况,还有现在的EXPLAIN信息。
      

  2.   

    select t1.model_room_id, t1.model_room_name, t1.design_explain, t9.user_name, t1.cost, t1.area, t2.room_name,
          t7.house_type_name, t10.house_name, t11.building_name, t8.district_name, t1.status, t1.source, t1.create_time, t1.modify_time
    from model_room t1, room t2, dstyle t3, model_room_style t4, model_room_color t5, color t6, house_type t7, district t8, user t9, house t10, building t11
    where t1.user_id=t9.user_id and t1.room_id=t2.room_id and t1.house_type_id=t7.house_type_id and t1.house_id=t10.house_id
         and t1.building_id=t11.building_id and t1.district_id=t8.district_id 
         and t4.style_id=t3.style_id and t5.color_id=t6.color_id and t4.model_room_id=t1.model_room_id and t5.model_room_id=t1.model_room_id
    LIMIT 1,10
      

  3.   

    EXPLAIN select ...贴一下结果,然后再 show index from tablename1 贴出来以供分析。