SQL query [MySQL] optimize?
Hi all, I have probably two questions
1. where can I read about how to actually perform the queries in MySQL? the thing that used to be clear which places are narrow, you want to understand in what order and by what rules it all happens
For example if I have a query of the form
SELECT DISTINCT s.c_id as c_id ,( SELECT IF (s0.period_id=1, s0.sum*180, IF (s0.period_id=2, s0.sum*4.5, IF (s0.period_id=3, s0.sum, IF (s0.period_id=4, s0.sum/12, 0) ) ) ) as monthly ...<br>
and then comes join with 10tyu! tables and a large where clause at the end with the grouping and order
and explain shows that
id select_type table type possible_keys key key_len ref rows Extra<br>
1 PRIMARY s ALL c_id,sum_idx 117108 NULL NULL NULL Using where; Using temporary; Using filesort<br>
and then another 10 lines. in 3 subsequent connection of type eq_ref
and the rest of ref
from the manual it says that
For each combination of rows from previous tables will be read one row from this table<br>
combination of strings in my case is 117 tons of lines? or something else?
Does the nested select each time for each line? or not?
How to understand the "why" in the query is so slow fetching?
Sorry can't put the entire query :(
asked October 10th 19 at 12:45
Try to use the profiler tool, the article was even here:
Also from experience I suspect that a lot of time may be spent on group and order.
to write before the query EXPLAIN, no?
Find more questions by tags MySQLSQLSearch engine optimization