Re: Query optimization with repeated calculations

2018-01-19 Thread Tom Lane
Robert McGehee writes: > I frequently want to make views that repeat a calculation over and over > again in lots of columns. In the example below, let’s say it’s (a+b), but > we can imagine the calculation being much more complicated. > For example: > CREATE VIEW AS > SELECT (a+b)*c as c1, (a+b)*

Query optimization with repeated calculations

2018-01-19 Thread Robert McGehee
Hello, I have a general query optimization question involving repeated calculations. I frequently want to make views that repeat a calculation over and over again in lots of columns. In the example below, let’s say it’s (a+b), but we can imagine the calculation being much more complicated. For ex