Optimization of inner joins in mysql query

I have been working with mysql almost 3 years and now i am struck very badly and it is all about the query performance because the tables i am dealing with having records in millions so please suggest me what to do.

I have to fetch dada from 6 tables

table_1
table_2
table_3
table_4
table_5
table_6

Now i tell you how -

table_1/table_2/table_3/table_4 have left join and fetching id out of it. - Lets say this is step A .
Then I fetch all order_id from table_6 - Let’s say this is step B.

Now i search step A using IN(id) AND step B using NOT IN(order_id) into table_5 which screw my query because table_5 has 300k records and table_6 has 200k records so please can someone suggest me what to do?

If my question is not clear then i can send screenshot also.

Looking forward to hear from you soon and thanks in advance!

You should post your DB schema (not pictures). This smells of a really bad database design.

First of all thanks for the response benanamen and yes i send you schema.
And to be honest i can not change the schema.

Well, lets see what your working with so we can figure something out.

please run SHOW CREATE TABLE tablename for each table – this will also show us which indexes the tables have

also please post your actual query

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.