Home >Backend Development >PHP Tutorial >How to sort millions of data in php+mysql_PHP tutorial
How to sort millions of data in php+mysql?
php+mysql million-level data paging. Because it involves joint queries with multiple tables and multiple conditions. Can anyone help optimize the following query statement?
if(empty($wheresql)){
$wheresql="where aid>=(SELECT aid FROM `tj_logs` LIMIT $sqlfirst,1) limit $shownu";
}else{
$wheresql.=" and aid>=(SELECT aid FROM `tj_logs` LIMIT $sqlfirst,1) limit $shownu";
}
$query=mysql_query("SELECT DISTINCT A.*,B.url,C.username FROM `tj_logs` A LEFT JOIN `tj_domain` B ON A.wid=B.wid LEFT JOIN `tj_members` C ON A. uid=C.uid $wheresql");
------Solution--------------------
In a sense, you should adopt redundant design to exchange redundancy for efficiency. This is the so-called anti-paradigm design