Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
sql-refreshmaterializedview.html59 linesDownload Raw Back to html
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>REFRESH MATERIALIZED VIEW</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-reassign-owned.html" title="REASSIGN OWNED" /><link rel="next" href="sql-reindex.html" title="REINDEX" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">REFRESH MATERIALIZED VIEW</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-reassign-owned.html" title="REASSIGN OWNED">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-reindex.html" title="REINDEX">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-REFRESHMATERIALIZEDVIEW"><div class="titlepage"></div><a id="id-1.9.3.162.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">REFRESH MATERIALIZED VIEW</span></h2><p>REFRESH MATERIALIZED VIEW — replace the contents of a materialized view</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">3REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <em class="replaceable"><code>name</code></em>4    [ WITH [ NO ] DATA ]5</pre></div><div class="refsect1" id="id-1.9.3.162.5"><h2>Description</h2><p>6   <code class="command">REFRESH MATERIALIZED VIEW</code> completely replaces the7   contents of a materialized view.  To execute this command you must be the8   owner of the materialized view.  The old contents are discarded.  If9   <code class="literal">WITH DATA</code> is specified (or defaults) the backing query10   is executed to provide the new data, and the materialized view is left in a11   scannable state.  If <code class="literal">WITH NO DATA</code> is specified no new12   data is generated and the materialized view is left in an unscannable13   state.14  </p><p>15   <code class="literal">CONCURRENTLY</code> and <code class="literal">WITH NO DATA</code> may not16   be specified together.17  </p></div><div class="refsect1" id="id-1.9.3.162.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">CONCURRENTLY</code></span></dt><dd><p>18      Refresh the materialized view without locking out concurrent selects on19      the materialized view.  Without this option a refresh which affects a20      lot of rows will tend to use fewer resources and complete more quickly,21      but could block other connections which are trying to read from the22      materialized view.  This option may be faster in cases where a small23      number of rows are affected.24     </p><p>25      This option is only allowed if there is at least one26      <code class="literal">UNIQUE</code> index on the materialized view which uses only27      column names and includes all rows;  that is, it must not be an28      expression index or include a <code class="literal">WHERE</code> clause.29     </p><p>30      This option may not be used when the materialized view is not already31      populated.32     </p><p>33      Even with this option only one <code class="literal">REFRESH</code> at a time may34      run against any one materialized view.35     </p></dd><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>36      The name (optionally schema-qualified) of the materialized view to37      refresh.38     </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.162.7"><h2>Notes</h2><p>39   If there is an <code class="literal">ORDER BY</code> clause in the materialized40   view's defining query, the original contents of the materialized view41   will be ordered that way; but <code class="command">REFRESH MATERIALIZED42   VIEW</code> does not guarantee to preserve that ordering.43  </p></div><div class="refsect1" id="id-1.9.3.162.8"><h2>Examples</h2><p>44   This command will replace the contents of the materialized view called45   <code class="literal">order_summary</code> using the query from the materialized46   view's definition, and leave it in a scannable state:47</p><pre class="programlisting">48REFRESH MATERIALIZED VIEW order_summary;49</pre><p>50  </p><p>51   This command will free storage associated with the materialized view52   <code class="literal">annual_statistics_basis</code> and leave it in an unscannable53   state:54</p><pre class="programlisting">55REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA;56</pre></div><div class="refsect1" id="id-1.9.3.162.9"><h2>Compatibility</h2><p>57   <code class="command">REFRESH MATERIALIZED VIEW</code> is a58   <span class="productname">PostgreSQL</span> extension.59  </p></div><div class="refsect1" id="id-1.9.3.162.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-creatematerializedview.html" title="CREATE MATERIALIZED VIEW"><span class="refentrytitle">CREATE MATERIALIZED VIEW</span></a>, <a class="xref" href="sql-altermaterializedview.html" title="ALTER MATERIALIZED VIEW"><span class="refentrytitle">ALTER MATERIALIZED VIEW</span></a>, <a class="xref" href="sql-dropmaterializedview.html" title="DROP MATERIALIZED VIEW"><span class="refentrytitle">DROP MATERIALIZED VIEW</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-reassign-owned.html" title="REASSIGN OWNED">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-reindex.html" title="REINDEX">Next</a></td></tr><tr><td width="40%" align="left" valign="top">REASSIGN OWNED </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> REINDEX</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai