title: Postgres materialized view of last n months
body: <p>I want to keep data of last 12 months in a materialized view in Postgresql.</p>
  
  <pre><code>CREATE MATERIALIZED VIEW IF NOT EXISTS last_12_months AS 
  SELECT a, b, c FROM mytable 
  WHERE created_at &gt; date_trunc('day',('now'::timestamp - '1 year'::interval)));
  </code></pre>
  
  <p>The problem is that 'now' is evaluated in view creation so data will grow forever and I would like to have a fixed range of data. </p>
  
  <p>I saw that views doesn't accept parameters. I thought drop/create view everyday but I'm sure that there are better alternatives. </p>