Posts

Showing posts from August, 2013

optimizing MySQL database by indexing tutorial

Optimizing MySQL: Queries and Indexes   You know the scene. The database is just too slow. Queries are queuing up, backlogs growing, users being refused connection. Management is ready to spend millions on "upgrading" to some other system, when the problem is really that MySQL is simply not being used properly. Badly defined or non-existent MySQL indexes are one of the primary reasons for poor performance, and fixing these can often lead to phenomenal improvements. Consider an extreme example: CREATE TABLE employee (    employee_number char(10) NOT NULL,    firstname varchar(40),    surname varchar(40),    address text,    tel_no varchar(25),    salary int(11),    overtime_rate int(10) NOT NULL ); To find employee Fred Jone's salary(employee number 101832), you run: SELECT salary FROM employee WHERE employee_number = '101832'; MySQL has no clue where to find this record. It doesn't even know that if it does find one matching, that there will not be