Optimizing MySQL
Today i have encounter a problem where mysql used by our clients got hang.
And after 2 days of searching, i finally know that using too many left join (joining mysql table) while NOT INDEXING it would make database queries too long that can cause database hang.
The solution this situation is by using mysql index.
To retrieve rows from other tables when performing joins. MySQL can use indexes on columns more efficiently if they are declared as the same type and size. In this context,
VARCHARandCHARare considered the same if they are declared as the same size. For example,VARCHAR(10)andCHAR(10)are the same size, butVARCHAR(10)andCHAR(15)are not.Comparison of dissimilar columns may prevent use of indexes if values cannot be compared directly without conversion. Suppose that a numeric column is compared to a string column. For a given value such as
1in the numeric column, it might compare equal to any number of values in the string column such as'1',' 1','00001', or'01.e1'. This rules out use of any indexes for the string column.from http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html
You can read more about this and how to create indexes as below:








