SQL查询从php加载非常慢,但在phpmyadmin中加载速度很快

时间:2016-04-21 00:46:12

标签: php sql performance phpmyadmin return

我正在研究学校管理系统应用程序。以下查询直接在phpmyadmin运行非常快,但从php页面返回非常慢。我的SQL语句:

 SELECT stuinfo.stuid,
       stuclassinfo.ID,
       stuinfo.stuname,
       stuclassinfo.roll,
       stuclassinfo.Group,
       stuclassinfo.Section,
       stuclassinfo.FourthSub
  FROM stuclassinfo
 inner join stuinfo
    on stuclassinfo.stuid = stuinfo.stuid
 where stuinfo.InsID = '1001'
   and stuclassinfo.InsID = '1001'
   and stuclassinfo.ClassName = 'Nine'
   and stuclassinfo.Section = 'A'
   and stuclassinfo.Shift = 'Morning'
   and stuclassinfo.year = '2015'
   AND stuclassinfo.stuid NOT In
       (SELECT stuid
          FROM stuclassinfo
         where InsID = '1001'
           and Shift = 'Morning'
           and year = '2016'
           and ClassName = 'Ten')
 order by stuclassinfo.roll

但是它的返回速度很快,而不遵循部分代码“AND stuclassinfo.stuid NOT In (SELECT stuid FROM stuclassinfo where InsID='1001' and Shift='Morning' and year='2016' and ClassName='Ten')"

任何想法为什么会出现这样的差异?

0 个答案:

没有答案