今天写了个多表查询,忘了写条件了,一执行,结果主机处于死机状态,
等了好久才出现个提示:
“SQL ERROR(2008):MySQL Client ran out of Memory”,QQ也处于离线状态。执行语句如下:
select
a.intime  AA
,b.intime   BB
,c.intime   CC
,d.intime   DD
,e.intime   EE
,f.intime   FF
,G.intime   GG
,h.intime   HH
,i.intime  II
,j.intime  JJ
,k.intime  KK
,l.intime  LL
#,m.singindatetime road
from TB1 a,TB2 b,TB3 c,TB4 d,TB5 e,TB6 f,
TB7 g,TB8 h,TB9 i,TB10 j,
TB11 k,TB12 l

解决方案 »

  1.   

    explain select
    a.intime  AA
    ,b.intime      BB
    ,c.intime      CC
    ,d.intime      DD
    ,e.intime      EE
    ,f.intime      FF
    ,G.intime      GG
    ,h.intime      HH
    ,i.intime  II
    ,j.intime  JJ
    ,k.intime  KK
    ,l.intime  LL
    #,m.singindatetime road
    from TB1 a,TB2 b,TB3 c,TB4 d,TB5 e,TB6 f,
    TB7 g,TB8 h,TB9 i,TB10 j,
    TB11 k,TB12 l贴出来看一下。
      

  2.   

    from TB1 a,TB2 b,TB3 c,TB4 d,TB5 e,TB6 f,
    TB7 g,TB8 h,TB9 i,TB10 j,
    TB11 k,TB12 l
    这么多表的笛卡尔积
    客户端内存不足,无法存储全部的查询数据导致失败
      

  3.   

    id;"select_type";"table";"type";"possible_keys";"key";"key_len";"ref";"rows";"Extra"
    1;  "SIMPLE";   "e";  "ALL";  NULL;  NULL;  NULL;  NULL;  "338";  ""
    1;  "SIMPLE";   "f";  "ALL";  NULL;  NULL;  NULL;  NULL;  "598";  ""
    1;  "SIMPLE";   "l";  "ALL";  NULL;  NULL;  NULL;  NULL;  "713";  ""
    1;  "SIMPLE";   "c";  "ALL";  NULL;  NULL;  NULL;  NULL;  "728";  ""
    1;  "SIMPLE";   "k";  "ALL";  NULL;  NULL;  NULL;  NULL;  "729";  ""
    1;  "SIMPLE";   "j";  "ALL";  NULL;  NULL;  NULL;  NULL;  "739";  ""
    1;  "SIMPLE";   "b";  "ALL";  NULL;  NULL;  NULL;  NULL;  "776";  ""
    1;  "SIMPLE";   "d";  "ALL";  NULL;  NULL;  NULL;  NULL;  "921";  ""
    1;  "SIMPLE";   "h";  "ALL";  NULL;  NULL;  NULL;  NULL;  "1816";  ""
    1;  "SIMPLE";   "g";  "ALL";  NULL;  NULL;  NULL;  NULL;  "2045";  ""
    1;  "SIMPLE";   "i";  "ALL";  NULL;  NULL;  NULL;  NULL;  "2425";  ""
    1;  "SIMPLE";   "a";  "ALL";  NULL;  NULL;  NULL;  NULL;  "11703";  "Using where"顺便说下,
    我加了
    where a.ID=...=l.ID limit 1;
    就很快了。不过不是想要的结果,我想他们按ORDERY BY intime DESC 排列,该怎么做?
      

  4.   

    where XXXX
    order by intime desc
      

  5.   

    这样不行的。
    因为每个表都有intime ,系统不知道用那个 。
    再说,我自己都写出 ORDERY BY intime DESC ,肯定是不行的。
      

  6.   

    难道这样可以?where (tb1 a order by intime desc),(tb2 b order by intime desc),....