select case count (currentprice) when 60 then round (avg (currentprice), 2) the else 0 end as avg60 from (select currentprice from stocks where stockcode='600795' order by closedate desc limit 803, 60) as t
Calculate the average data, is too slow, the greater the number of limit behind the slower,,
CodePudding user response:
So complex queries, whether certain need to throw to the database real-time calculation, calculation on a regular basis can consider the background, and then save the results, need to take the data directly from the existing results,CodePudding user response:
Select currentprice from stocks where stockcode='600795' order by closedate desc limit 803, 60Slow in this sentence, must try to optimize this statement,
CodePudding user response:
Table structure or something?CodePudding user response:
Depots watch is your stocks, so the query time depots and key condition, you these stocks should be inventory table number must be large, such sweeping all watch is slow