donglei_0507 2012-10-21 02:06
浏览 64
已采纳

在php页面中优化大数据

I'm trying to speed up the time it takes to query 200K rows of data and show it in a web page, it normally takes around 20-30 seconds, but currently I've gotten it down to around 7-10 seconds. I still need it to go around 3-7 seconds at most.

In my query, I'm selecting all the rows in a single table and placing around 5 columns into the PHP script. The query goes like this:

SELECT * FROM table where company = ? and division = ?;

I just add the parameters from my session. Then I send the query and the parameters in a .inc file and the inc runs the query. But it also runs a separate query for pagination of data. then it would compare the 2 queries to check for any irregularities between the two. Then it will place the data in a new window.

Are there any known algorithms or techniques I could use to speed up the process? I've already removed any garbage code and sped up some functions but it's still slow.

P.S.: I also just handled the system around 2 days ago so I'm still familiarizing the structure.

  • 写回答

2条回答 默认 最新

  • doubeng3216 2012-10-21 02:08
    关注

    First, make sure there's an index on that table. If your queries include both company and division in your where clause, a compound index across the fields would work well.

    Second, don't run a second query for pagination! Run the first query with a limit clause, cache what you need to, and then paginate from there.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料