website logo
⌘K
🏠Homepage
πŸ‘‹Introduction
Key Concepts & Architecture
πŸš€Run Oxla in 2 minutes
πŸƒβ€β™‚οΈRun Oxla on S3
πŸ›«Multi-node Deployment
πŸ‘¨β€πŸ’»SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
Comment Support
🚨Error Handling
πŸ†šDifferences Between Oxla vs. PostgreSQL
πŸ“ˆPublic Metrics
Docs powered by
Archbee
SQL Reference
...
SQL Functions
Other Functions

pg_total_relation_size

6min

Overview

The pg_total_relation_size function allows you to retrieve the size of a table. This function is useful for monitoring the storage requirements.

Syntax

The syntax for the pg_total_relation_size function is as follows:

Pgsql
|
pg_total_relation_size('relation_name');
ο»Ώ

Here, relation_name is the name of the table for which you want to determine the size.

Output

The pg_total_relation_size function returns the size of the specified table in bytes.

Example

1) First, let’s assume we have a table named users. Use the below query to create the table.

Pgsql
|
CREATE TABLE users (
    username TEXT,
    email TEXT
);
INSERT INTO users (username, email) VALUES
    ('john_doe', '[email protected]'),
    ('jane_smith', '[email protected]'),
    ('alice_smith', '[email protected]'),
    ('bob_jones', '[email protected]'),
    ('susan_wilson', '[email protected]'),
    ('michael_jackson', '[email protected]'),
    ('lisa_johnson', '[email protected]'),
    ('david_smith', '[email protected]');
ο»Ώ

2) In this case, we will use the pg_total_relation_size function to determine the size of a users table.

Pgsql
|
SELECT pg_total_relation_size('users');
ο»Ώ

3) This query will return the size of the users table in bytes.

Pgsql
|
 pg_total_relation_size 
------------------------
                    556
ο»Ώ

ο»Ώ

Updated 13 Sep 2023
Did this page help you?
PREVIOUS
NULLIF
NEXT
has_schema_privilege()
Docs powered by
Archbee
TABLE OF CONTENTS
Overview
Syntax
Output
Example
Docs powered by
Archbee

Dedicated to data analytics that provides 10x faster execution of analytical queries than current state of the art solutions. We are launching SOON! Join the waiting list for more info.




Β©2023 Oxla