sql query joins multiple tables - too slow (8 tables)

前端 未结 8 2059
借酒劲吻你
借酒劲吻你 2020-11-30 23:22

i\'m trying to join 8 tables into one in order to create index used by other application, my query is like : (my mysql skill\'s very amateur)

SELECT t1_id, t         


        
8条回答
  •  盖世英雄少女心
    2020-11-30 23:33

    From your query plan I can conclude that the tables referred to as s, n and q do not have an index on the field they are being joined on.

    Since there are lot of rows in these tables (about 400,000 rows in their cartesian product) and MySQL's only way to do JOIN's is using NESTED LOOPS, it will really take forever.

    Create an index on these tables or define the joined field as a PRIMARY KEY.

提交回复
热议问题