There is a program that first queries a certain number of users $ data from the user table, then the foreach array, from the user table count (*) wherepid $ value [& #039; id & #039;] It takes more than five seconds to count the number of subsets. If there are too many data estimates, it will be stuck. How can this problem be optimized? There is a program that first queries a certain number of users $ data from the user table, then the foreach array, from the user table count (*) where pid = $ value ['id'] to count the number of subsets
It takes more than five seconds to cycle 200 data records. If there are too many data records, the system will be stuck. How can we optimize it?
Reply content:
There is a program that first queries a certain number of users $ data from the user table, then the foreach array, from the user table count (*) where pid = $ value ['id'] to count the number of subsets
It takes more than five seconds to cycle 200 data records. If there are too many data records, the system will be stuck. How can we optimize it?
Connection Query count (*) using group
Using Count (1) instead of count (*) can be improved.