doudao3170 2017-04-08 22:59
浏览 64

优化highstock sql的加载时间

I'm using highstock to virtualize some weather data stored in a continuously expanding MySQL database. As the database is getting bigger, the website loading times increased quite a bit. At first I was glad that I've got highstock working as I'm not really into JavaScript and PHP but now I'm looking for a way to improve the loading times.

Right now I'm using 4 different series to show temperatur, humidity, luminance and soil humidity. To import the data I'm using one php script for each series as the last code shows. I don't know how to use only one php script to pass all data over at once neither if that would save any time. But it is definetly the php scripts that take the longest as running them independently takes some time.

Preview Chart

My index.html: https://pastebin.com/KUZfbLjC (there are some strange spaces/tabs that are not in the original file for some reason)

sql_temperature.php:

if (date("I")) {$offset = 7200;} #Offset for daylight saving time
else {$offset = 3600;}

$pdo = new PDO('mysql:host=localhost;dbname=***', '***', '***');

$sql = "select UNIX_TIMESTAMP(Timestamp), Temperature from sensors";
foreach ($pdo->query($sql) as $row) {
   $datetime = ($row[0] + $offset) * 1000;
   $data[] = array((float)$datetime,(float) $row[1]);
}

echo json_encode($data);

So if there is anything to optimize here please let me know.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图