forked from docs/doc-exports
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>
117 lines
14 KiB
HTML
117 lines
14 KiB
HTML
<a name="EN-US_TOPIC_0000001445318666"></a><a name="EN-US_TOPIC_0000001445318666"></a>
|
|
|
|
<h1 class="topictitle1">Database Object Size Functions</h1>
|
|
<div id="body0000001445318666"><p id="EN-US_TOPIC_0000001445318666__aaee277591227423fb6bbcb7e402014ac">Database object size functions calculate the actual disk space used by database objects.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section87122010201418"><h4 class="sectiontitle">pg_column_size(any)</h4><p id="EN-US_TOPIC_0000001445318666__aac6e660f56764ccbbfa16111eda556d3">Description: Specifies the number of bytes used to store a particular value (possibly compressed).</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a31a1e8dd2eb548ddbff14e082d879016">Return type: integer</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a975d7c142da24eae93a5bb72908b6df8">Note: <strong id="EN-US_TOPIC_0000001445318666__b5988509179423">pg_column_size</strong> displays the space for storing an independent data value.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001445318666__s0e44c94b77fe44e89fcf92089e5ccf68"><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">pg_column_size</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
|
|
<span class="w"> </span><span class="n">pg_column_size</span><span class="w"> </span>
|
|
<span class="c1">----------------</span>
|
|
<span class="w"> </span><span class="mi">4</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 class="section" id="EN-US_TOPIC_0000001445318666__section2720324181411"><h4 class="sectiontitle">pg_database_size(oid)</h4><p id="EN-US_TOPIC_0000001445318666__a468b89ddea2e433a86aac31fd9b9ad0b">Description: Specifies the disk space used by the database with the specified OID.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a02a1a82df63944138cb6e43fca5ab96b">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section13317538101414"><h4 class="sectiontitle">pg_database_size(name)</h4><p id="EN-US_TOPIC_0000001445318666__ad90e375c29bd4294acac9ef273920641">Description: Specifies the disk space used by the database with the specified name.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ab6fe1ec740994329aaaa6f69312c8651">Return type: bigint</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a745e30b874114f2abbbd3df9ac8feca2">Note: <strong id="EN-US_TOPIC_0000001445318666__b2970672819423">pg_database_size</strong> receives the OID or name of a database and returns the disk space used by the corresponding object.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ad25fe4c172c9471da2a5ce7e48ca46b8">Example:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001445318666__sed0d9ecf8c7246f49210581dfd6f9266"><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">pg_database_size</span><span class="p">(</span><span class="s1">'gaussdb'</span><span class="p">);</span>
|
|
<span class="w"> </span><span class="n">pg_database_size</span><span class="w"> </span>
|
|
<span class="c1">------------------</span>
|
|
<span class="w"> </span><span class="mi">51590112</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 class="section" id="EN-US_TOPIC_0000001445318666__section48933529144"><h4 class="sectiontitle">pg_relation_size(oid)</h4><p id="EN-US_TOPIC_0000001445318666__a294766ef27b748888330492d6f45bdb6">Description: Specifies the disk space used by the table with a specified OID or index.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a6e5262617ab84a9fbcedbc8241900205">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section1388726131510"><h4 class="sectiontitle">get_db_source_datasize()</h4><p id="EN-US_TOPIC_0000001445318666__p210912510197">Description: Estimates the total size of non-compressed data in the current database.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__p21096258193">Return type: bigint</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__p9109102510191">Note: (1) <strong id="EN-US_TOPIC_0000001445318666__b4076816859423">ANALYZE</strong> must be performed before this function is called. (2) Calculate the total size of non-compressed data by estimating the compression rate of column-store tables.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__p1810952531919">Example:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001445318666__screen14971319192417"><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>
|
|
<span class="normal">6</span>
|
|
<span class="normal">7</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">analyze</span><span class="p">;</span>
|
|
<span class="k">ANALYZE</span>
|
|
<span class="k">SELECT</span><span class="w"> </span><span class="n">get_db_source_datasize</span><span class="p">();</span>
|
|
<span class="w"> </span><span class="n">get_db_source_datasize</span>
|
|
<span class="c1">------------------------</span>
|
|
<span class="w"> </span><span class="mi">35384925667</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 class="section" id="EN-US_TOPIC_0000001445318666__section122251041171514"><h4 class="sectiontitle">pg_relation_size(text)</h4><p id="EN-US_TOPIC_0000001445318666__a090f49da938349e088e9693bdb593658">Description: Specifies the disk space used by the table with a specified name or index. The table name can be schema-qualified.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__acce0ad5bc0e1489999be91de754d4ac2">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section13222656191513"><h4 class="sectiontitle">pg_relation_size(relation regclass, fork text)</h4><p id="EN-US_TOPIC_0000001445318666__ad87008d13de5492a9b99f60c12e21469">Description: Specifies the disk space used by the specified bifurcating tree ('main', 'fsm', or 'vm') of a certain table or index.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a448f438f84014df8b2e2cd681be1c4f1">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section36072815167"><h4 class="sectiontitle">pg_relation_size(relation regclass)</h4><p id="EN-US_TOPIC_0000001445318666__a8c104e0320c945c391a126d7b74e9f5c">Description: Is an abbreviation of <strong id="EN-US_TOPIC_0000001445318666__b12394139529423">pg_relation_size(..., 'main')</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a8cae5a23799c4085a49fbad40eab4b84">Return type: bigint</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ae66fd4876a744ed1892bd2e805fe481e">Note: <strong id="EN-US_TOPIC_0000001445318666__b7388764199423">pg_relation_size</strong> receives the OID or name of a table, index, or compressed table, and returns the size.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section482353051613"><h4 class="sectiontitle">pg_partition_size(oid,oid)</h4><p id="EN-US_TOPIC_0000001445318666__aad83715f59604f28b2654c27acc2774b">Description: Specifies the disk space used by the partition with a specified OID. The first <strong id="EN-US_TOPIC_0000001445318666__b11908738759423">oid</strong> is the OID of the table and the second <strong id="EN-US_TOPIC_0000001445318666__b14822113609423">oid</strong> is the OID of the partition.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__aff2154382b854625ada1e49d966c7f13">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section17721345191615"><h4 class="sectiontitle">pg_partition_size(text, text)</h4><p id="EN-US_TOPIC_0000001445318666__aabe8e7db6f704ee6a6f64be8519bdefb">Description: Specifies the disk space used by the partition with a specified name. The first <strong id="EN-US_TOPIC_0000001445318666__b20433346929423">text</strong> is the table name and the second <strong id="EN-US_TOPIC_0000001445318666__b15090163579423">text</strong> is the partition name.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ab69479fd3f544e07893c783b0d37683b">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section72869234181"><h4 class="sectiontitle">pg_partition_indexes_size(oid,oid)</h4><p id="EN-US_TOPIC_0000001445318666__a3f60855c70ab46a9a34c03deb6eecd10">Description: Specifies the disk space used by the index of the partition with a specified OID. The first <strong id="EN-US_TOPIC_0000001445318666__b12392682629423">oid</strong> is the OID of the table and the second <strong id="EN-US_TOPIC_0000001445318666__b93724519423">oid</strong> is the OID of the partition.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a16f80c96d5ed4e7abb1980aacfb7fd59">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section16116642111817"><h4 class="sectiontitle">pg_partition_indexes_size(text,text)</h4><p id="EN-US_TOPIC_0000001445318666__a989d7095a3a0408aa50bcc6a8fc6b509">Description: Specifies the disk space used by the index of the partition with a specified name. The first <strong id="EN-US_TOPIC_0000001445318666__b11639664659423">text</strong> is the table name and the second <strong id="EN-US_TOPIC_0000001445318666__b4247420139423">text</strong> is the partition name.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a4170ff92660246fdba03cacc6b02bc2b">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section1794640142012"><h4 class="sectiontitle">pg_indexes_size(regclass)</h4><p id="EN-US_TOPIC_0000001445318666__a54aa4a7bbee54e7aada7afc8092dbb37">Description: Specifies the total disk space used by the index appended to the specified table.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a3a6a4e3b35454b0bbeaae78bd7f4554f">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section1363210555206"><h4 class="sectiontitle">pg_size_pretty(bigint)</h4><p id="EN-US_TOPIC_0000001445318666__a2891d6c3b88b4a4c8dffbc6f2b8c78d3">Description: Converts the calculated byte size into a size readable to human beings.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a4f13374133ac4050834cb0768c5b3fa3">Return type: text</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section196986122112"><h4 class="sectiontitle">pg_size_pretty(numeric)</h4><p id="EN-US_TOPIC_0000001445318666__a67978263329444b8a010e41a88938279">Description: Converts the calculated byte size indicated by a numeral into a size readable to human beings.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ac2e566935c8b409597d4a5c9db6c27f2">Return type: text</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__aaa358b6179194e1384089ff9a26a8a10">Note: <strong id="EN-US_TOPIC_0000001445318666__b15215688319423">pg_size_pretty</strong> formats the results of other functions into a human-readable format. KB/MB/GB/TB can be used.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section79241433102120"><h4 class="sectiontitle">pg_table_size(regclass)</h4><p id="EN-US_TOPIC_0000001445318666__ad046ecbdb22942f6ba79661d280fd286">Description: Specifies the disk space used by the specified table, excluding indexes (but including TOAST, free space mapping, and visibility mapping).</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a019f9f9f5b664624b9d3f6ba112e048d">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section1197517366230"><h4 class="sectiontitle">pg_total_relation_size(oid)</h4><p id="EN-US_TOPIC_0000001445318666__a1cb0f0b0e65949aeb760a5d84fd96dd5">Description: Specifies the disk space used by the table with a specified OID, including the index and the compressed data.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a3ddf029c502143da8f4b9884047aebf9">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section103282047142310"><h4 class="sectiontitle">pg_total_relation_size(regclass)</h4><p id="EN-US_TOPIC_0000001445318666__a7560858b96fc4be0bea566e8f0c6dcfd">Description: Specifies the total disk space used by the specified table, including all indexes and TOAST data.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ade7c6651990d48898077a6983ebb1cbf">Return type: bigint</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001445318666__section435495717236"><h4 class="sectiontitle">pg_total_relation_size(text)</h4><p id="EN-US_TOPIC_0000001445318666__a7e4e36f9265242ab9c4b36191120ef44">Description: Specifies the disk space used by the table with a specified name, including the index and the compressed data. The table name can be schema-qualified.</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__a193de2485a834bd782d45f015c927c76">Return type: bigint</p>
|
|
<p id="EN-US_TOPIC_0000001445318666__ab15fff7915324bbabcc889b2368a36bc">Note: <strong id="EN-US_TOPIC_0000001445318666__b814293689423">pg_total_relation_size</strong> receives the OID or name of a table or a compressed table, and returns the sizes of the data, related indexes, and the compressed table in bytes.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0058.html">Database Object Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|