dongshang1934 2018-11-06 10:04
浏览 56

PHP MySQL大数据集,有很多时间显示在角度组件和从数据库导出的小csv文件中

EDIT

I selected only one field from all the query, the file size reduced to 433Kb but the display time was 13 seconds.

END OF EDIT

I have the following query:

SELECT *,  DATE(h.hh_date_added) as dateOnly FROM unit u 
                    INNER JOIN househ h
                    ON u.unit_id=h.unit_id
                    LEFT JOIN location l
                    ON l.location_id_auto=u.location_id_auto
                    LEFT JOIN user us
                    ON us.user_id = h.user_id
                    ORDER BY dateOnly DESC

When running it on phpmyadmin, it is executed within 0.233 seconds returning 11331 row with nearly 20 fields.

If I export the data into csv or excel, the size of it would be 830Kb.

When returning this result using php to angular 6's httpclient service to display it in an angular material table:

getDataByType(){
    this.showSpinner=true;
    this.auth.getDataByType(this.dataType).subscribe(
      (data)=>
      {
        console.log(data)
        this.dataSource = new MatTableDataSource(Object.values(data));
        this.dataSource.paginator = this.paginator;
        this.dataSource.sort=this.sort;
        this.showSpinner=false;
      },
      (error)=>
      {
        console.log("Error: "+error)
      }
    )


  }

It would take more than 30 seconds (As displayed in the content-download time) to the data to be displayed in the table and shown to the user.

The timing was displayed on the timing tab of google chrome network tab with a file size of 15.9 Mb.

Why the file size is so huge ?

  1. Is the problem from the material table that took too much time to display data after receiving them:

I don't think so, as testing it on postman returned the same file size with different time of 20 seconds.

  1. or because of a query error which is returning a huge data set:

which I don't think so as on server computer, the result was returned within less than seconds with an excel file less than 1 Mb of size.

  1. Is it because I am returning it as json encoded data and chrome is taking some time to handle it ?

No, because I try to send the data within an array without the use of json_encode function and still giving the same size even bigger (17Mb).

So is it local area network/router problem making the download time huge or other thing ?

Please refer to my previous question on stack to check the connection scripts to the local server.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。