# pg_total_relation_size

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: pg_total_relation_size
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/other-functions/pg-total-relation-size
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/other-functions/pg-total-relation-size.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/other-functions/pg-total-relation-size.adoc
description: The pg_total_relation_size() function retrieves the size of a table and is useful for monitoring storage requirements.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/other-functions/pg-total-relation-size.md -->

The [`pg_total_relation_size()`](https://www.postgresql.org/docs/current/functions-admin.html) is a database object size function that retrieves the size of a table and is useful for monitoring the storage requirements.

## [](#syntax)Syntax

```sql
pg_total_relation_size('relation_name');
```

It returns the size of the specified table in bytes.

## [](#parameters)Parameters

-   `relation_name`: Name of the table to determine the size for.


## [](#examples)Examples

Create a `users` table:

```sql
CREATE TABLE users (
    username TEXT,
    email TEXT
);
INSERT INTO users (username, email) VALUES
    ('john_doe', 'john.doe@example.com'),
    ('jane_smith', 'jane.smith@example.com'),
    ('alice_smith', 'alice.smith@example.com'),
    ('bob_jones', 'bob.jones@example.com'),
    ('susan_wilson', 'susan.wilson@example.com'),
    ('michael_jackson', 'michael.jackson@example.com'),
    ('lisa_johnson', 'lisa.johnson@example.com'),
    ('david_smith', 'david.smith@example.com');
```

Use the `pg_total_relation_size()` function to determine the size of the `users` table (in bytes):

```sql
SELECT pg_total_relation_size('users');
```

The query returns:

```sql
 pg_total_relation_size
------------------------
                    556
```