1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.496 2010/01/15 09:18:58 heikki Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.497 2010/01/19 05:50:18 tgl Exp $ -->
2
2
3
3
<chapter id="functions">
4
4
<title>Functions and Operators</title>
@@ -13173,12 +13173,12 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13173
13173
</entry>
13174
13174
<entry><type>text</type></entry>
13175
13175
<entry>Get last transaction log location received and synced to disk during
13176
- streaming recovery. If streaming recovery is still in progress
13177
- this will increase monotonically. If streaming recovery has completed
13178
- then this value will remain static at the value of the last WAL record
13179
- received and synced to disk during that recovery. When the server has
13180
- been started without a streaming recovery then the return value will be
13181
- InvalidXLogRecPtr (0/0).
13176
+ streaming recovery. If streaming recovery is still in progress
13177
+ this will increase monotonically. If streaming recovery has completed
13178
+ then this value will remain static at the value of the last WAL record
13179
+ received and synced to disk during that recovery. When the server has
13180
+ been started without a streaming recovery then the return value will be
13181
+ InvalidXLogRecPtr (0/0).
13182
13182
</entry>
13183
13183
</row>
13184
13184
<row>
@@ -13187,11 +13187,11 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13187
13187
</entry>
13188
13188
<entry><type>text</type></entry>
13189
13189
<entry>Get last transaction log location replayed during recovery.
13190
- If recovery is still in progress this will increase monotonically.
13191
- If recovery has completed then this value will remain static at
13192
- the value of the last WAL record applied during that recovery.
13193
- When the server has been started normally without a recovery
13194
- then the return value will be InvalidXLogRecPtr (0/0).
13190
+ If recovery is still in progress this will increase monotonically.
13191
+ If recovery has completed then this value will remain static at
13192
+ the value of the last WAL record applied during that recovery.
13193
+ When the server has been started normally without a recovery
13194
+ then the return value will be InvalidXLogRecPtr (0/0).
13195
13195
</entry>
13196
13196
</row>
13197
13197
</tbody>
@@ -13207,19 +13207,25 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13207
13207
<primary>pg_column_size</primary>
13208
13208
</indexterm>
13209
13209
<indexterm>
13210
- <primary>pg_database_size </primary>
13210
+ <primary>pg_total_relation_size </primary>
13211
13211
</indexterm>
13212
13212
<indexterm>
13213
- <primary>pg_relation_size </primary>
13213
+ <primary>pg_table_size </primary>
13214
13214
</indexterm>
13215
13215
<indexterm>
13216
- <primary>pg_size_pretty</primary>
13216
+ <primary>pg_indexes_size</primary>
13217
+ </indexterm>
13218
+ <indexterm>
13219
+ <primary>pg_database_size</primary>
13217
13220
</indexterm>
13218
13221
<indexterm>
13219
13222
<primary>pg_tablespace_size</primary>
13220
13223
</indexterm>
13221
13224
<indexterm>
13222
- <primary>pg_total_relation_size</primary>
13225
+ <primary>pg_relation_size</primary>
13226
+ </indexterm>
13227
+ <indexterm>
13228
+ <primary>pg_size_pretty</primary>
13223
13229
</indexterm>
13224
13230
13225
13231
<table id="functions-admin-dbsize">
@@ -13238,44 +13244,48 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13238
13244
</row>
13239
13245
<row>
13240
13246
<entry>
13241
- <literal><function>pg_database_size </function>(<type>oid </type>)</literal>
13247
+ <literal><function>pg_total_relation_size </function>(<type>regclass </type>)</literal>
13242
13248
</entry>
13243
13249
<entry><type>bigint</type></entry>
13244
- <entry>Disk space used by the database with the specified OID</entry>
13250
+ <entry>
13251
+ Total disk space used by the table with the specified OID or name,
13252
+ including all indexes and <acronym>TOAST</> data
13253
+ </entry>
13245
13254
</row>
13246
13255
<row>
13247
13256
<entry>
13248
- <literal><function>pg_database_size </function>(<type>name </type>)</literal>
13257
+ <literal><function>pg_table_size </function>(<type>regclass </type>)</literal>
13249
13258
</entry>
13250
13259
<entry><type>bigint</type></entry>
13251
- <entry>Disk space used by the database with the specified name</entry>
13260
+ <entry>
13261
+ Disk space used by the table with the specified OID or name,
13262
+ excluding indexes (but including TOAST, free space map, and visibility
13263
+ map)
13264
+ </entry>
13252
13265
</row>
13253
13266
<row>
13254
13267
<entry>
13255
- <literal><function>pg_relation_size </function>(<parameter>relation</parameter> < type>regclass</type>, <parameter>fork</parameter> <type>text </type>)</literal>
13268
+ <literal><function>pg_indexes_size </function>(<type>regclass</type>)</literal>
13256
13269
</entry>
13257
13270
<entry><type>bigint</type></entry>
13258
13271
<entry>
13259
- Disk space used by the specified fork (<literal>'main'</literal>,
13260
- <literal>'fsm'</literal> or <literal>'vm'</>)
13261
- of the table or index with the specified OID or name
13272
+ Total disk space used by indexes attached to the table with the
13273
+ specified OID or name
13262
13274
</entry>
13263
13275
</row>
13264
13276
<row>
13265
13277
<entry>
13266
- <literal><function>pg_relation_size </function>(<parameter>relation</parameter> < type>regclass </type>)</literal>
13278
+ <literal><function>pg_database_size </function>(<type>oid </type>)</literal>
13267
13279
</entry>
13268
13280
<entry><type>bigint</type></entry>
13269
- <entry>
13270
- Shorthand for <literal>pg_relation_size(..., 'main')</literal>
13271
- </entry>
13281
+ <entry>Disk space used by the database with the specified OID</entry>
13272
13282
</row>
13273
13283
<row>
13274
13284
<entry>
13275
- <literal><function>pg_size_pretty </function>(<type>bigint </type>)</literal>
13285
+ <literal><function>pg_database_size </function>(<type>name </type>)</literal>
13276
13286
</entry>
13277
- <entry><type>text </type></entry>
13278
- <entry>Converts a size in bytes into a human-readable format with size units </entry>
13287
+ <entry><type>bigint </type></entry>
13288
+ <entry>Disk space used by the database with the specified name </entry>
13279
13289
</row>
13280
13290
<row>
13281
13291
<entry>
@@ -13293,14 +13303,31 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13293
13303
</row>
13294
13304
<row>
13295
13305
<entry>
13296
- <literal><function>pg_total_relation_size </function>(<type>regclass</type>)</literal>
13306
+ <literal><function>pg_relation_size </function>(<parameter>relation</parameter> < type>regclass</type>, <parameter>fork</parameter> <type>text </type>)</literal>
13297
13307
</entry>
13298
13308
<entry><type>bigint</type></entry>
13299
13309
<entry>
13300
- Total disk space used by the table with the specified OID or name,
13301
- including indexes and <acronym>TOAST</> data
13310
+ Disk space used by the specified fork (<literal>'main'</literal>,
13311
+ <literal>'fsm'</literal> or <literal>'vm'</>)
13312
+ of the table or index with the specified OID or name
13302
13313
</entry>
13303
13314
</row>
13315
+ <row>
13316
+ <entry>
13317
+ <literal><function>pg_relation_size</function>(<parameter>relation</parameter> <type>regclass</type>)</literal>
13318
+ </entry>
13319
+ <entry><type>bigint</type></entry>
13320
+ <entry>
13321
+ Shorthand for <literal>pg_relation_size(..., 'main')</literal>
13322
+ </entry>
13323
+ </row>
13324
+ <row>
13325
+ <entry>
13326
+ <literal><function>pg_size_pretty</function>(<type>bigint</type>)</literal>
13327
+ </entry>
13328
+ <entry><type>text</type></entry>
13329
+ <entry>Converts a size in bytes into a human-readable format with size units</entry>
13330
+ </row>
13304
13331
</tbody>
13305
13332
</tgroup>
13306
13333
</table>
@@ -13310,6 +13337,26 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13310
13337
data value.
13311
13338
</para>
13312
13339
13340
+ <para>
13341
+ <function>pg_total_relation_size</> accepts the OID or name of a
13342
+ table or toast table, and returns the total on-disk space used for
13343
+ that table, including all associated indexes. This function is
13344
+ equivalent to <function>pg_table_size</function>
13345
+ <literal>+</> <function>pg_indexes_size</function>.
13346
+ </para>
13347
+
13348
+ <para>
13349
+ <function>pg_table_size</> accepts the OID or name of a table and
13350
+ returns the disk space needed for that table, exclusive of indexes.
13351
+ (TOAST space, free space map, and visibility map are included.)
13352
+ </para>
13353
+
13354
+ <para>
13355
+ <function>pg_indexes_size</> accepts the OID or name of a table and
13356
+ returns the total disk space used by all the indexes attached to that
13357
+ table.
13358
+ </para>
13359
+
13313
13360
<para>
13314
13361
<function>pg_database_size</function> and <function>pg_tablespace_size</>
13315
13362
accept the OID or name of a database or tablespace, and return the total
@@ -13318,14 +13365,17 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13318
13365
13319
13366
<para>
13320
13367
<function>pg_relation_size</> accepts the OID or name of a table, index or
13321
- toast table, and returns the size in bytes. Specifying
13368
+ toast table, and returns the on-disk size in bytes. Specifying
13322
13369
<literal>'main'</literal> or leaving out the second argument returns the
13323
13370
size of the main data fork of the relation. Specifying
13324
13371
<literal>'fsm'</literal> returns the size of the
13325
13372
Free Space Map (see <xref linkend="storage-fsm">) associated with the
13326
13373
relation. Specifying <literal>'vm'</literal> returns the size of the
13327
13374
Visibility Map (see <xref linkend="storage-vm">) associated with the
13328
- relation.
13375
+ relation. Note that this function shows the size of only one fork;
13376
+ for most purposes it is more convenient to use the higher-level
13377
+ functions <function>pg_total_relation_size</> or
13378
+ <function>pg_table_size</>.
13329
13379
</para>
13330
13380
13331
13381
<para>
@@ -13334,12 +13384,6 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
13334
13384
appropriate.
13335
13385
</para>
13336
13386
13337
- <para>
13338
- <function>pg_total_relation_size</> accepts the OID or name of a
13339
- table or toast table, and returns the size in bytes of the data
13340
- and all associated indexes and toast tables.
13341
- </para>
13342
-
13343
13387
<para>
13344
13388
The functions shown in <xref
13345
13389
linkend="functions-admin-genfile"> provide native access to
0 commit comments