补充资料
以下是主要部分代码,帮帮我还可以怎么写才最优化? ///////$recordcount定义每一页所要显示的记录数////////////////
    $pagerecords=10;
    ////////读取page当前页号/////////////////////////
    $page=$_GET["page"];
    if($page=="")
    {
      $page=1;
    }
    ///////计算当前页号所对应的记录的开始处$start/////////
    $start=$pagerecords*($page-1);
    ///////编写查询当前页号的记录///////////////////////////
$select_sprod = "select PSPID,PUID,PID,Pname,Pno,Para,Price,Photo,Pstock,";
$select_sprod .= "Pfact,Pack,Plotno,Pspeci from products where ";
$select_sprod .= "PSPID in (select SPID from sproducts where SGPID =$GPID) order by Pdate desc limit $start,$pagerecords";
//echo $select_sprod;
////////编写获取总记录数的SQL语句//////////////////////
$selectCount="select count(*) from products where PSPID in (select SPID from sproducts where SGPID =$GPID) order by Pdate desc ";
$result_sprod = mysql_query($select_sprod);
$resultCount=mysql_query($selectCount);
list($totalrecords)=mysql_fetch_row($resultCount); 
while($arr_sprod = mysql_fetch_array($result_sprod))
{
$select_user = "select Utruename,Ucompany,Utel,Uemail from users where UID='$arr_sprod[PUID]'";
$result = mysql_query($select_user);
$arr_str = mysql_fetch_array($result);

解决方案 »

  1.   

    我的产品分大类小类和产品信息表,小类有大类ID:SGPID,产品信息表有小类ID:PSPID;数据库里有一百万条记录了,每访问这个页面就要等待很长时间.........
      

  2.   

    试用JOIN这个关联了,结果效果更差了,有什么方法,这个页面访问慢的题呢
      

  3.   

    作为where 和order by 的列你都加了索引吗?
      

  4.   

    http://news.csdn.net/n/20061207/98991.html系统的看看这个,自己改进下吧...
      

  5.   

    把mysql 语句弄到缓存里面 还有就是 select 后面 如果用不到的字段 不要查询出来,查询出来的话也会在用内存
      

  6.   

    (select SPID from sproducts where SGPID =$GPID)  可以把这个事先查询出来 放到一个数组中 在 用 in ()  还有就是 最后 where 条件 和order by 的字段能有关系!!!
      

  7.   

    1 做好字段索引.
    2 做联合查询后,再过滤.
    3 做好查询数据的cache. 
      

  8.   

    数据结构有问题 产品有两个属性 完全可以用两个字段来表示select * from products where group=? order by Pdate desc limit 0,30既然分页了 应该用limit 具体怎么获得分类编号和分类名称对应 方法有很多 可以用表存储 缓存成数组100W数量级应该没问题 如果更多应该考虑分表了 如何分要考虑查询 无法给出建议