donglei_0507 2012-10-20 18: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-20 18: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条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部