Monthly Archives: April 2013

Mysql high traffic with join table

Recently I encounter a trouble shooting. This is a high traffic system which record each of member all the hits and impression. And base on those records, system will decide next page site display order.
We got a lot of complain that it took too long time loading up next page and even more blank pages. In system backend, there are a bunch of lost db connection error. After dig deep, found out the script query using join. Most of developer like using join or sorting to do the query, yes, even me. It is clear and easy written down in script. But I did test, join and sorting require pull out select result into tmp, then msyql base on the tmp finish whole action. Although we could say tmp only using virtual or memory, will wipe off in very short time. But in high traffic, it will explode memory.
Well,if we only do select in query, and using array handle all the join and sorting. seems this way much faster and with no error.
So I brought up another question. Why php array handle much faster than mysql query handle.