I want to create a MATERIALIZED VIEW
called ohlc
that calculates the OHLC values of a stock's price. Stock prices are stored in an append-only price
table.
The pricing data is updated regularly but ohlc
is only refreshed once per hour. This got me thinking... Is it possible to bridge the gap by layering a VIEW
on top of the MATERIALIZED VIEW
?
Meaning, is it possible to define a VIEW
that would return values from the ohlc
table if they exists; and otherwise calculate the values on the fly? This means that the majority of rows would come from the cache, and only the most recent data would have to get calculated on the fly.
Is such a thing possible? If so, how?