Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Database Object Functions

Updated on 2022-07-29 GMT+08:00

Database Object Size Functions

Database object size functions calculate the actual disk space used by database objects.

  • pg_column_size(any)

    Description: Specifies the number of bytes used to store a particular value (possibly compressed).

    Return type: int

    Note: pg_column_size displays the space for storing an independent data value.

    1
    2
    3
    4
    5
    SELECT pg_column_size(1);
     pg_column_size 
    ----------------
                  4
    (1 row)
    
  • pg_database_size(oid)

    Description: Specifies the disk space used by the database with the specified OID.

    Return type: bigint

  • pg_database_size(name)

    Description: Specifies the disk space used by the database with the specified name.

    Return type: bigint

    Note: pg_database_size receives the OID or name of a database and returns the disk space used by the corresponding object.

    For example:

    1
    2
    3
    4
    5
    SELECT pg_database_size('gaussdb');
     pg_database_size 
    ------------------
             51590112
    (1 row)
    
  • pg_relation_size(oid)

    Description: Specifies the disk space used by the table with a specified OID or index.

    Return type: bigint

  • get_db_source_datasize()

    Description: Estimates the total size of non-compressed data in the current database.

    Return type: bigint

    Note: (1) ANALYZE 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.

    For example:

    1
    2
    3
    4
    5
    6
    7
    analyze;
    ANALYZE
    select get_db_source_datasize();
     get_db_source_datasize
    ------------------------
                35384925667
    (1 row)
    
  • pg_relation_size(text)

    Description: Specifies the disk space used by the table with a specified name or index. The table name can be schema-qualified.

    Return type: bigint

  • pg_relation_size(relation regclass, fork text)

    Description: Specifies the disk space used by the specified bifurcating tree ('main', 'fsm', or 'vm') of a certain table or index.

    Return type: bigint

  • pg_relation_size(relation regclass)

    Description: Is an abbreviation of pg_relation_size(..., 'main').

    Return type: bigint

    Note: pg_relation_size receives the OID or name of a table, index, or compressed table, and returns the size.

  • pg_partition_size(oid,oid)

    Description: Specifies the disk space used by the partition with a specified OID. The first oid is the OID of the table and the second oid is the OID of the partition.

    Return type: bigint

  • pg_partition_size(text, text)

    Description: Specifies the disk space used by the partition with a specified name. The first text is the table name and the second text is the partition name.

    Return type: bigint

  • pg_partition_indexes_size(oid,oid)

    Description: Specifies the disk space used by the index of the partition with a specified OID. The first oid is the OID of the table and the second oid is the OID of the partition.

    Return type: bigint

  • pg_partition_indexes_size(text,text)

    Description: Specifies the disk space used by the index of the partition with a specified name. The first text is the table name and the second text is the partition name.

    Return type: bigint

  • pg_indexes_size(regclass)

    Description: Specifies the total disk space used by the index appended to the specified table.

    Return type: bigint

  • pg_size_pretty(bigint)

    Description: Converts the calculated byte size into a size readable to human beings.

    Return type: text

  • pg_size_pretty(numeric)

    Description: Converts the calculated byte size indicated by a numeral into a size readable to human beings.

    Return type: text

    Note: pg_size_pretty formats the results of other functions into a human-readable format. KB/MB/GB/TB can be used.

  • pg_table_size(regclass)

    Description: Specifies the disk space used by the specified table, excluding indexes (but including TOAST, free space mapping, and visibility mapping).

    Return type: bigint

  • pg_total_relation_size(oid)

    Description: Specifies the disk space used by the table with a specified OID, including the index and the compressed data.

    Return type: bigint

  • pg_total_relation_size(regclass)

    Description: Specifies the total disk space used by the specified table, including all indexes and TOAST data.

    Return type: bigint

  • pg_total_relation_size(text)

    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.

    Return type: bigint

    Note: pg_total_relation_size 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.

Database Object Position Functions

  • pg_relation_filenode(relation regclass)

    Description: Specifies the ID of a filenode with the specified relationship.

    Return type: oid

    Description: pg_relation_filenode receives the OID or name of a table, index, sequence, or compressed table, and returns the filenode number allocated to it. The filenode is the basic component of the file name used by the relationship. For most tables, the result is the same as that of pg_class.relfilenode. For the specified system directory, relfilenode is 0 and this function must be used to obtain the correct value. If a relationship that is not stored is transmitted, such as a view, this function returns NULL.

  • pg_relation_filepath(relation regclass)

    Description: Specifies the name of a file path with the specified relationship.

    Return type: text

    Description: pg_relation_filepath is similar to pg_relation_filenode, except that pg_relation_filepath returns the whole file path name for the relationship (relative to the data directory PGDATA of the database cluster).

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback