mysql查询需要很多时间才能给我结果

时间:2018-10-24 13:14:59

标签: mysql

我在数字海洋上有带双核和4 GB ram的云服务器。在该服务器上,mysql的一个表有94,028,872+行,并且每秒递增。 当我想尝试从该表格中获取数据时,需要花费很多时间。

SELECT
    vehicle_tabel.id,
    DATE_FORMAT(CONVERT_TZ(vehicle_tabel.devicetime, '-00:00', '+05:30'),
        '%D %b %Y %r') devicetime,
    IFNULL(ROUND(JSON_EXTRACT(vehicle_tabel.attributes, '$.totalDistance') / 1000, 2), '0') AS routkm,
    vehicle_tabel.latitude,
    vehicle_tabel.longitude,
    ROUND((vehicle_tabel.speed)*1.852, 2) AS speed,
    vehicle_tabel.course,
    IFNULL(ROUND(JSON_EXTRACT(vehicle_tabel.attributes, '$.fuel'), 2), '0') AS fuel 
FROM `vehicle_tabel`
WHERE
    deviceid = 252 AND
    vehicle_tabel.devicetime BETWEEN
        CONVERT_TZ(2018-09-01 00:00:00, '-00:00', '-05:30') AND
        CONVERT_TZ(2018-09-03 00:00:00, '-00:00', '-05:30') AND
    (vehicle_tabel.latitude != 0 OR vehicle_tabel.longitude != 0 ) AND
    vehicle_tabel.id % 2 = 1 AND
    attributes->'$.motion' = true
ORDER BY
    vehicle_tabel.devicetime ASC

这是简单的查询。我想提高mysql性能,并在短时间内查询给我数据。有什么建议吗?

0 个答案:

没有答案