还是mysql设置或是mysql版本有问题?测试的版本是mysql3.23.58。因为听说mysql3比4和5要稳定一些。

解决方案 »

  1.   

    SELECT m.uid, m.username, m.gender, m.email, m.regdate, m.lastvisit, m.posts, m.credits,
    m.showemail, mf.nickname, mf.site, mf.location FROM cdb_members m
    LEFT JOIN cdb_memberfields mf USING(uid)  ORDER BY uid LIMIT 0, 25;
    -----------------------and 
    -----------------------SELECT m.uid, m.username, m.gender, m.email, m.regdate, m.lastvisit, m.posts, m.credits, m.showemail FROM cdb_members m order by m.uid LIMIT 0, 25;SELECT mf.uid,mf.nickname, mf.site, mf.location FROM cdb_memberfields mf ORDER BY mf.uid LIMIT 0, 25;
    -----------------------They are not the same. They won't return the same result.
      

  2.   

    SELECT m.uid, m.username, m.gender, m.email, m.regdate, m.lastvisit, m.posts, m.credits,
    m.showemail, mf.nickname, mf.site, mf.location FROM cdb_members m
    LEFT JOIN cdb_memberfields mf USING(uid)  ORDER BY uid -----------------------------
    It will return all the data from the first table (cdb_members), and the data from the second table (cdb_memberfields) which the uid of it also exists in the first table (cdb_members).
      

  3.   

    将之拆分为两条语句后可以得到同样的结果(自己合并一下)。-------------------------------
    How much time you spend to combine the two results ?
      

  4.   

    你有多少数据?用explain看一下,不会那么慢的
      

  5.   

    我用explain看过了。应该没问题才对。数据有十来万。但用了limit应该只是显示前15而已。
      

  6.   

    按dz原本的写法要1秒。拆成2条,一条是0.002一条是0.001。差别太大了。是不是mysql3.23版的left join不管有没有limit都进行了全表left join?
      

  7.   

    测试程序很简单。
    ob_start();
    microtime();
    执行sql
    比较microtime();
    显示执行时间经过测试,不论是分成2条,还是直接把order by 去掉都是执行0.003秒。但原样执行就是1秒左右。explain的结果table m mf
    type index eq_ref
    possible_keys NULL primary
    key primary primary
    key_len 3 3
    ref NULL m.uid
    rows 173378 1
    Extra NULL NULL原样执行时间1秒左右。去掉order by后,table m的type变成all,这时执行时间只要0.003秒。
      

  8.   

    已证实在mysql3下执行速度比mysql4慢得多。在mysql4下正常。