我有一个气象站数据库,我想通过数据网格视图在 Visual Basic .Net 应用程序中查看。原始数据每 10 分钟由车站存入数据库,但我只得到一个降雨量,即全年的累计降雨量。在应用程序中,我想显示每个观察期的降雨量,并在底部显示当天的累积量。一切正常,但我在 MySQL 中编写的这个查询需要永远运行。有没有办法优化这个?
更新:
抱歉,我认为图像会显示得更好,这里是查询:(粗体部分是什么太慢了)
SELECT
d.RecordIDNumber,
d.RecDateTime,
d.AirTemp_F_Avg,
d.AirTemp_F_Min,
DATE_FORMAT(d.AirTemp_F_TMn, '%H:%i') AS 'AirTemp_F_TMn',
d.AirTemp_F_Max,
DATE_FORMAT(d.AirTemp_F_TMx, '%H:%i') AS 'AirTemp_F_TMx',
d.RH_Avg,
d.Barometer_iHg,
d.BatVolt_V,
d.BatVolt_V_Min,
d.ETo_in,
d.RainYearly_in,
d.Solar_Avg,
d.WindSpeed_mph_Avg,
d.WindSpeed_mph_Max,
DATE_FORMAT(d.WindSpeed_mph_TMx, '%H:%i') AS 'WindSpeed_mph_TMx',
d.WindSpeed_mph_WVc1,
d.Wind_Direction,
ROUND(35.74 + 0.6215 * d.AirTemp_F_Avg
- 35.75 * POW(d.WindSpeed_mph_Avg, 0.16)
+ 0.4275 * d.AirTemp_F_Avg * POW(d.WindSpeed_mph_Avg, 0.16),2) AS 'WindChill',
ROUND((17.625 - LOG(d.RH_Avg / 100)
- ((17.625 * d.AirTemp_F_Avg) / (243.04 + d.AirTemp_F_Avg))), 2) AS 'Dewpoint',
d.RainYearly_in - ( SELECT
MIN(d2.RainYearly_in)
FROM
data d2
WHERE
DATE_FORMAT(d2.RecDateTime, '%Y-%m-%d')
= DATE_FORMAT(d.RecDateTime, '%Y-%m-%d') )
FROM
data d
WHERE
DATE_FORMAT(d.RecDateTime, '%Y-%m-%d') = '2013-11-01'
AND d.RecordIDNumber <> -1
ORDER BY
d.RecDateTime DESC