Monday, October 31, 2011

optimize mysql with index

if you want to join large table, indexing may help.

table1: 30,000 rows
table2: 40 rows

indexing for example user ID may speed up select query

SELECT name, phoneNo, address FROM table1 INNER JOIN table2 ON table1.userid = table2.userid

with no index, query takes about 8second
but with index query only 0.4second

No comments:

Related Posts Plugin for WordPress, Blogger...