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
On this page

Show all

Segment-Page Storage Functions

Updated on 2023-10-23 GMT+08:00
  • local_segment_space_info(tablespacename TEXT, databasename TEXT)

    Description: Generates usage information about all extent groups in the tablespace of the current node.

    Return type:

    node_name

    Node name

    extent_size

    Extent specifications of an extent group. The unit is the number of blocks.

    forknum

    Fork number

    total_blocks

    Total number of extents in a physical file

    meta_data_blocks

    Number of blocks occupied by the metadata managed in a tablespace, including the space header and map page but excluding the segment head

    used_data_blocks

    Number of extents used for storing data, including the segment head

    utilization

    Percentage of the number of used blocks to the total number of blocks, that is, (the value of used_data_blocks + the value of meta_data_block)/the value of total_blocks

    high_water_mark

    High-water mark, indicating the number of allocated extents and maximum physical page number. Blocks that exceed the high-water mark are not used and can be directly recycled.

    Example:

    select * from local_segment_space_info('pg_default', 'postgres');
         node_name     | extent_size | forknum | total_blocks | meta_data_blocks | used_data_blocks | utilization | high_water_mark 
    -------------------+-------------+---------+--------------+------------------+------------------+-------------+-----------------
     dn_6001_6002_6003 |           1 |       0 |        16384 |             4157 |                1 |     .253784 |            4158
     dn_6001_6002_6003 |           8 |       0 |        16384 |             4157 |                8 |     .254211 |            4165
    (2 rows)
  • global_segment_space_info(tablespacename TEXT, databasename TEXT)

    Description: Returns the usage information of all nodes in the cluster. The effect is similar to that of local_segment_space_info.

  • pg_stat_segment_extent_usage(int4 tablespace oid, int4 database oid, int4 extent_type, int4 forknum)

    Description: Specifies the usage information of each allocated extent in an extent group returned each time. extent_type indicates the type of the extent group. The value is an integer ranging from 1 to 5. If the value is not within the range, an error is reported. forknum indicates the fork number. The value is an integer ranging from 0 to 4. Currently, only the following values are valid: 0 for data files, 1 for FSM files, and 2 for visibility map files.

    Return type:

    Name

    Description

    start_block

    Start physical page number of an extent

    extent_size

    Size of an extent

    usage_type

    Usage type of an extent, for example, segment head and data extent

    ower_location

    Object location of an extent to which a pointer points. For example, the owner of a data extent is the head of the segment to which the data extent belongs.

    special_data

    Position of an extent in its owner. The value of this field is related to the usage type. For example, special data of a data extent is the extent ID in the segment to which the data extent belongs.

    The value of usage_type is enumerated. The meaning of each value is as follows:

    • Non-bucket table segment head: data segment head of a non-hash bucket table
    • Non-bucket table fork head: Fork segment header of a non-segment-page table
    • Bucket table main head: primary table segment header of a hash bucket table
    • Bucket table map block: Map block of a hash bucket table
    • Bucket segment head: segment head of each bucket in a hash bucket table
    • Data extent: data block

    Example:

    select * from pg_stat_segment_extent_usage((select oid::int4 from pg_tablespace where spcname='pg_default'), (select oid::int4 from pg_database where datname='postgres'), 1, 0);
    start_block | extent_size |       usage_type       | ower_location | special_data
    -------------+-------------+------------------------+---------------+--------------
    4157 |           1 | Bucket table main head |    4294967295 |            0
    4158 |           1 | Bucket table map block |          4157 |            0
    4159 |           1 | Bucket table map block |          4157 |            1
    4160 |           1 | Bucket table map block |          4157 |            2
    4161 |           1 | Bucket table map block |          4157 |            3
    4162 |           1 | Bucket table map block |          4157 |            4
    4163 |           1 | Bucket table map block |          4157 |            5
    4164 |           1 | Bucket table map block |          4157 |            6
    4165 |           1 | Bucket table map block |          4157 |            7
    4166 |           1 | Bucket table map block |          4157 |            8
  • local_space_shrink(tablespacename TEXT, databasename TEXT)

    Description: Shrinks specified physical segment-page space on the current node. Only the currently connected database can be shrank.

    Return value: empty

  • gs_space_shrink(int4 tablespace, int4 database, int4 extent_type, int4 forknum)

    Description: Works similar to local_space_shrink. That is, shrinks specified physical segment-page space. However, the parameters are different. The input parameters are the OIDs of the tablespace and database, and the value of extent_type is an integer ranging from 2 to 5. Note: The value 1 of extent_type indicates segment-page metadata. Currently, the physical file that contains the metadata cannot be shrunk. This function is used only by tools. You are not advised to use it directly.

    Return value: empty

  • global_space_shrink(tablespacename TEXT, databasename TEXT)

    Description: Compresses segment-page storage space on all DNs in a cluster. This is performed on a CN.

    Note: If global_space_shrink locks the cluster. DDL operations cannot be performed. local_space_shrink does not lock the cluster.

  • pg_stat_remain_segment_info()

    Description: Displays residual extents on the current node due to faults. Residual extents are classified into two types: segments that are allocated but not used and extents that are allocated but not used. The main difference is that a segment contains multiple extents. During reclamation, all extents in the segment need to be recycled.

    Return type:

    Name

    Description

    space_id

    Tablespace ID

    db_id

    Database ID

    block_id

    Extent ID

    type

    Extent type. The options are as follows: ALLOC_SEGMENT, DROP_SEGMENT, and SHRINK_EXTENT.

    The values of type are described as follows:
    • ALLOC_SEGMENT: When a user creates a segment-page table and the segment is just allocated but the transaction of creating a table is not committed, the node is faulty. As a result, the segment is not used after being allocated.
    • DROP_SEGMENT: When a user deletes a segment-page table and the transaction is successfully committed, the bit corresponding to the segment page of the table is not reset and a fault, such as power failure, occurs. As a result, the segment is not used or released.
    • SHRINK_EXTENT: When a user shrinks a segment-page table and does not release the idle extent, a fault, such as power failure, occurs. As a result, the extent remains and cannot be reused.
    Example:
    select * from pg_stat_remain_segment_info();
    space_id | db_id | block_id | type
    ----------+-------+----------+------
    1663       |   16385|        4156| ALLOC_SEGMENT
  • pg_free_remain_segment(int4 spaceId, int4 dbId, int4 segmentId)

    Description: Releases a specified residual extent. The value must be obtained from the pg_stat_remain_segment_info function. The function verifies input values. If the specified extent is not among the recorded residual extents, an error message is returned. If the specified extent is a single extent, the extent is released independently. If it is a segment, the segment and all extents in the segment are released.

    Return value: empty

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