开发者

A way to store a frequently queried column in SQLite?

I have a query that involves finding response times several times in a row, like so:

ROUND(AVG(T.FinishTime-T.StartTime),3) AS 'Average', MAX(T.FinishTime-T.StartTime) AS 'Max', MIN(T.FinishTime-T.StartTime)

Now, I don't fully understand how SQL processes this stuff in the background, but from my general knowledge of coding, is it not better to make the sub开发者_开发技巧traction T.FinishTime-T.StartTime more efficient? i.e. can the calculation be done once and then the aggregates found on that list of calculations? Or is it already done this way? I just want to try and cut my queries down into more efficient and readable chunks. I thought at first a view of T.FinishTime-T.StartTime could be made and that aggregates carried out on this, but then I read that views still calculate each time they are used.

Help appreciated!


Why do you think that calculation such a simple expression slows down your application by any significant amount?

Premature optimization is the root of all evil, they say. You may be wasting your time on something completely ineffectual. Profile first, optimize later. If you don't profile, don't optimize, period.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜