Re: How should I config the my.ini(or my.cnf) file for mysql?
Posted by: Rick James
Date: March 24, 2014 05:33PM

SHOW CREATE TABLE surveys;

The first SELECT probably needs these on `surveys`:
INDEX(Survey_Type, id_rep) for the inner query, and
INDEX(id_rep) for the JOIN.

chats probably needs
INDEX(chat_type, id_rep)

Aha, here is the real killer -- you have create temp tables without indexes.
Instead of "CREATE TEMPORARY TABLE Foo_Temp AS SELECT ...", do
CREATE TEMPORARY TABLE Foo_Temp (PRIMARY KEY id_rep) AS SELECT ...

That will make these _much_ more efficient:
Left Join Surveys_Temp As S ON S.Id_Rep = R.Id_Rep
Left Join Orders_Temp As O ON O.Id_Rep = R.Id_Rep
Left Join Chats_Temp As C on c.id_rep = R.Id_Rep

Also provide output of
EXPLAIN SELECT ...;
for each of the SELECTs -- those in the CREATEs, and the final query.

Options: ReplyQuote


Subject
Written By
Posted
Re: How should I config the my.ini(or my.cnf) file for mysql?
March 24, 2014 05:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.