Database Reference
In-Depth Information
cs_materialized_views ORDER BY sort_key LOOP
-- Now "mviews" has one record from
cs_materialized_views
PERFORM cs_log('Refreshing materialized
view ' || quote_ident(mviews.mv_name) || '
...');
EXECUTE 'TRUNCATE TABLE ' ||
quote_ident(mviews.mv_name);
EXECUTE 'INSERT INTO ' ||
quote_ident(mviews.mv_name) || ' ' ||
mviews.mv_query;
END LOOP;
PERFORM cs_log('Done refreshing
materialized views.');
RETURN 1;
END;
$$ LANGUAGE plpgsql;
The previous looping example shows a more complex function that refreshes the
data in some staging tables. These staging tables are designated "materialized
views" because the data is actually physically transferred to the staging tables. This
method is a common way to reduce query execution overhead for many presenta-
Search WWH ::




Custom Search