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条)

报告相同问题?

悬赏问题

  • ¥15 资源泄露软件闪退怎么解决?
  • ¥15 各位佬,下面的问题怎么用python实现?
  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化