doc-exports/docs/dws/dev/dws_04_0758.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

192 lines
18 KiB
HTML

<a name="EN-US_TOPIC_0000001188482310"></a><a name="EN-US_TOPIC_0000001188482310"></a>
<h1 class="topictitle1">PG_STAT_ALL_TABLES</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001188482310__a0e10c4b54a17446387b63e108175e061"><strong id="EN-US_TOPIC_0000001188482310__b10306945133813">PG_STAT_ALL_TABLES</strong> displays statistics about accesses to tables in the current database, including TOAST tables.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188482310__t21d8276558e848e4b1788eed4ad98821" frame="border" border="1" rules="all"><caption><b>Table 1 </b>PG_STAT_ALL_TABLES columns</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188482310__r5df81461681d4683a483a693160dd8b3"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.2.2.4.1.1"><p id="EN-US_TOPIC_0000001188482310__a14cc9abe4cf94931bda80a55477a250d"><strong id="EN-US_TOPIC_0000001188482310__b84235270691445">Name</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.2.2.4.1.2"><p id="EN-US_TOPIC_0000001188482310__a13a4fde5443d499aa7b94c704f1435a1">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="60%" id="mcps1.3.2.2.4.1.3"><p id="EN-US_TOPIC_0000001188482310__a8e3bf4ce43b5445587f5520950942c4e">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188482310__r555825e432d74251966715fccc3f54b1"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__ae9987430437d49ebb4064552be0a204b">relid</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a2b2574c9045642e19f33b74173f482f3">oid</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a2bf459e0c2614f4083b70f858f883e57">Table OID</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r65917687589b46499392ebe91f51f133"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a4cc80b7e98654edaad39dad95209e0cf">schemaname</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__add17413602f447d2ac816641a5c0da5d">name</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a5a0f75a0925a49bab589e7a3ff83443d">Schema name of the table</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r31dc179e090a4621a592780cdc0961ce"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a6257bf16cb3140c5b7f02b9b5a36f4cc">relname</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__afbeb6ece7e244233bf3a63ca9deb50ab">name</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a1a0097961c7847e3bab5859a64d8b8d2">Name of the table</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r4a92aea24e324bf3a1ae9e2e376c3230"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__ab9e9026478214683883315cea35319d1">seq_scan</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a05e6db7b52b3407d8bf373a3a4eaf00a">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__ae09eb3ac73844c19a0f5c67de1d5371f">Number of sequential scans started on the table</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__rb1984e86b1984a3aa05bf6999fb27d5f"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a4a0ac981226b46e0a8f11064a26d555c">seq_tup_read</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a95fbd8568b1b40ada17d1ad98a9f14a2">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__af87e5f36b4e247c1b4c852666893c583">Number of rows that have live data fetched by sequential scans</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__rc7c8132744e144f7b327d019f6c0817a"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__abbfab893f42342f9ac35b0b73f4bc4e7">idx_scan</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__aaae4cc9f0ffb49adacec29223cbec78c">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a8db3305f4c034d228ad8b49a1a6c4a35">Number of index scans</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r79bf92cdcd504a7fbd0f6e6339e8cd73"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a7d5dc50d3c514f2c821b446163426965">idx_tup_fetch</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a73b84044183c452fb4d7f6e5e5d7b0ef">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a30132da76fbd4c4b922ad4b17f5c67c9">Number of rows that have live data fetched by index scans</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__rb052d6cb88c4458eacabe1c583b0380e"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__afc5ae982ebde43fca96cc91da52b386a">n_tup_ins</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a2ff08db9bf314aba827ff5f8ac7928ff">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a5ec0c5d3804e43b4aed74e4ed2a05885">Number of rows inserted</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__re3e88a479e934bbbb93ae835942834ec"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a929b4076913c4e02b799a763018c6768">n_tup_upd</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a77765f856acd428bb1f8c4709894bf76">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a3d1cbc932b21497e93c9758a62736f36">Number of rows updated</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r054e81b280574c52876342fe3233a512"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a89e13552f8c74331b007e25a8917be71">n_tup_del</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a194647303c0a440bb938537f717ba7ec">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a3dc7ffa176bb428ea2acd6e751cc0846">Number of rows deleted</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r4f81268454044ae5afafac3f1ea9dd6d"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a720559e62a96478887964ea900dc3bac">n_tup_hot_upd</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a5da3f1839b0b457dac214109bd3d750e">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__acb7f981aaf5f4ffe8735a507cabe2fa7">Number of rows updated by <strong id="EN-US_TOPIC_0000001188482310__b103654503387">HOT</strong> (no separate index update is required)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__rb095ae394da14b92a853555d97dde9ff"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__ab9a306d7c86c462e8c8df14a4aa71429">n_live_tup</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a1988309c36f3444b803ac68d3eeab51e">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__ae4592ecb79eb4416a271fb4198fa36dc">Estimated number of live rows</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r286d6b5cbba14185a79388efd72ae15e"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a125e7ab9ddde4b80a28255df736adab4">n_dead_tup</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a16e7b3fc3bcb49f987a2796287f53a7e">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a6463e5f766e84434baa86aa0277acf44">Estimated number of dead rows</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r34ecb9bc87174ccf8a457c74e0b3760a"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a429e54add7f44e169b49b6a38597bf27">last_vacuum</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a31cfe4e1544747dc9aadd97c004034dc">timestamp with time zone</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__af5f51c40f701482c97a7ab417689423e">Last time at which this table was manually vacuumed (excluding <strong id="EN-US_TOPIC_0000001188482310__b153110454392">VACUUM FULL</strong>)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r1477966c5ea0493aa541c93b76ba36df"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a921ba8b0475144a8b9c65072ec7c52aa">last_autovacuum</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__aeef15b2624b44cad8eec993f3929ac53">timestamp with time zone</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a040e82b0b2fc4550a4b76b2bb80a6f6f">Last time at which this table was automatically vacuumed</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r21f1aeac94494add82d1a3848d2b36e1"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__ac65c487943ce4e019d6d8cafa2bcecab">last_analyze</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a79f3e330ed82417abdf58413d0c1b238">timestamp with time zone</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__aacdfb34180754f468589df7f6e880624">Last time at which this table was analyzed</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r9dc1e68ab09547509b674bc0fa6df22a"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a6701858dd6c547f2ad055c6256871c65">last_autoanalyze</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__a6d94b111a79346d18c41ae10400020d9">timestamp with time zone</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__aca42e98db86f45ea98d68b5d76b26b74">Last time at which this table was automatically vacuumed</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r7e0deaa546c34a29a0d70dcbd9482500"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a7859d41cb6104808b34d768f3f36c927">vacuum_count</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__acd803ba754474b3abb2d5faf1e3bfe84">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a9c1f3e2b0fde498ab656a3baccf55f6f">Number of vacuum operations (excluding <strong id="EN-US_TOPIC_0000001188482310__b58527804020">VACUUM FULL</strong>)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r54a13220f2b64e6d8f89b91007c5dadc"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a6e9a2ba8a34d4a12804f2ae20f81297e">autovacuum_count</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__aed991aa465bc448b9bd5c3edd80e51b5">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__aa522ffca60874aceab8a04df50ba7e70">Number of autovacuum operations</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r16d4c643382b41e1a017fe2161e9b67a"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__a9d59d125dfbb44b4930a1b5ca501c354">analyze_count</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__aa1c6d2e710ba42e9a173ab9cba981020">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__aa3d27e3383834e8599bb29b6c01ec34d">Number of analyze operations</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__r2ac217e316fd40a7bc3e2a91ba6b5c87"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__ae50c31305b5245e1a6fde6a96f4cd1bd">autoanalyze_count</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__ad164492f7262406ca4598d41f00fb22c">bigint</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__a4a530fe6f04c40778710379605a6f569">Number of autoanalyze operations</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482310__row1486851718273"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001188482310__p89781636182115">last_data_changed</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001188482310__p3978183662114">timestamp with time zone</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001188482310__p497803611213">Last time at which this table was updated (by <strong id="EN-US_TOPIC_0000001188482310__b1517713336401">INSERT</strong>/<strong id="EN-US_TOPIC_0000001188482310__b11178153324010">UPDATE</strong>/<strong id="EN-US_TOPIC_0000001188482310__b2017819334404">DELETE</strong> or <strong id="EN-US_TOPIC_0000001188482310__b111781233114020">EXCHANGE</strong>/<strong id="EN-US_TOPIC_0000001188482310__b1517916337401">TRUNCATE</strong>/<strong id="EN-US_TOPIC_0000001188482310__b1617913374020">DROP</strong> <em id="EN-US_TOPIC_0000001188482310__i817919337409">partition</em>). This column is recorded only on the local CN.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482310__section18241950102914"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001188482310__p18265955182919">Query the last data change time in the <strong id="EN-US_TOPIC_0000001188482310__b102589215418">table_test</strong> table:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482310__screen18574113133015"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">last_data_changed</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">PG_STAT_ALL_TABLES</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">relname</span><span class="w"> </span><span class="o">=</span><span class="s1">'table_test'</span><span class="p">;</span>
<span class="w"> </span><span class="n">last_data_changed</span>
<span class="c1">-------------------------------</span>
<span class="w"> </span><span class="mi">2024</span><span class="o">-</span><span class="mi">03</span><span class="o">-</span><span class="mi">27</span><span class="w"> </span><span class="mi">10</span><span class="p">:</span><span class="mi">28</span><span class="p">:</span><span class="mi">16</span><span class="p">.</span><span class="mi">277136</span><span class="o">+</span><span class="mi">08</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0639.html">System Views</a></div>
</div>
</div>