<div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">In
thefirst CF for 9.4 I plan to submit a patch to allow<br />transactional REFRESH of a materialized view using
differential<br/>update. Essentially I expect this to be the equivalent of running<br />the query specified for the
viewand saving the results into a<br />temporary table, and then doing DELETE and INSERT passes to make<br />the
matviewmatch the new data. If mv is the matview and mv_temp<br />is the temporary storage for the new value for its
data,the logic<br />would be roughly the equivalent of:<br /><br />BEGIN;<br />LOCK mv IN SHARE ROW EXCLUSIVE MODE;<br
/>CREATETEMP TABLE mv_temp AS [mv query];<br />-- Create indexes here??? Capture statistics on temp table???<br
/>DELETEFROM mv WHERE NOT EXISTS (SELECT * FROM mv_temp<br /> WHERE (mv_temp.*) IS NOT DISTINCT FROM (mv.*));<br
/>INSERTINTO mv SELECT * FROM mv_temp WHERE NOT EXISTS<br /> (SELECT * FROM mv WHERE (mv.*) IS NOT DISTINCT FROM
(mv_temp.*));<br/>COMMIT;<br /><br />I can see more than one way to code this, but would appreciate<br />input on the
bestway sooner rather than later, if anyone is going<br />to have an opinion.<br /><br />Thoughts?<br /><br />-- <br
/>KevinGrittner<br />EnterpriseDB: http://www.enterprisedb.com<br />The Enterprise PostgreSQL Company</div>