How to check table size Redshift in PostgreSQL

Galaxy Glossary

How can I check the size of a table in Amazon Redshift using SQL?

Use the system view SVV_TABLE_INFO or pg_total_relation_size() to quickly find the on-disk size of any Amazon Redshift table.

Sign up for the latest in SQL knowledge from the Galaxy Team!

Description

Why is checking table size important in Redshift?

Knowing table size helps you predict storage costs, tune vacuum and sort strategies, and spot runaway fact tables before they hurt query speed.

Which catalog view returns table size fast?

SVV_TABLE_INFO exposes table size in MB, uncompressed size, and percent skew without requiring superuser permissions.

How do I get the size of a single table?

SELECT table, size AS mb
FROM SVV_TABLE_INFO
WHERE table = 'orders';

This returns the compressed size of Orders in megabytes.

How do I list the 10 largest tables?

SELECT table, size AS mb
FROM SVV_TABLE_INFO
ORDER BY size DESC
LIMIT 10;

Sorts all user tables by size to reveal storage hotspots.

Can I include schemas and owners?

SELECT n.nspname AS schema,
c.relname AS table,
size/1024 AS gb,
u.usename AS owner
FROM SVV_TABLE_INFO t
JOIN pg_class c ON c.oid = t.table_id
JOIN pg_namespace n ON n.oid = c.relnamespace
JOIN pg_user u ON u.usesysid = c.relowner
ORDER BY gb DESC;

Adds rich context for multi-team clusters.

What if I need the exact disk footprint?

Use pg_total_relation_size()

SELECT
relname AS table,
pg_total_relation_size(oid) AS bytes
FROM pg_class
WHERE relname = 'orders';

This includes hidden TOAST and index data.

How can I visualize growth over time?

Create a nightly ETL that inserts SVV_TABLE_INFO results into a history table, then chart the trend to catch anomalies early.

Best practices for table-size queries

  • Filter by schema to avoid system tables.
  • Schedule queries during low load to reduce WLM queue pressure.
  • Alert when a table grows >20% week-over-week.

Common mistakes to avoid

Relying on uncompressed_size for billing and ignoring skew columns are frequent pitfalls—see below for fixes.

Need a quick recap?

Use SVV_TABLE_INFO for summaries and pg_total_relation_size() when you need byte-level accuracy.

.

Why How to check table size Redshift in PostgreSQL is important

How to check table size Redshift in PostgreSQL Example Usage


-- Find the five largest ecommerce tables
SELECT table   AS table_name,
       size    AS size_mb,
       uncompressed_size AS raw_mb,
       pct_skew AS skew
FROM SVV_TABLE_INFO
WHERE table IN ('customers','orders','products','orderitems')
ORDER BY size_mb DESC
LIMIT 5;

How to check table size Redshift in PostgreSQL Syntax


-- Size of one table in MB
SELECT table, size AS mb
FROM SVV_TABLE_INFO
WHERE table = 'orders';

-- Exact bytes including TOAST & indexes
SELECT pg_total_relation_size('public.orders') AS bytes;

-- Top-N largest tables with ecommerce context
SELECT table, size AS mb
FROM SVV_TABLE_INFO
WHERE schema = 'public'
  AND table IN ('customers','orders','products','orderitems')
ORDER BY size DESC;

Common Mistakes

Frequently Asked Questions (FAQs)

Does Redshift include indexes in table size?

Yes. Redshift stores only sort keys; their footprint is already included in the size column returned by SVV_TABLE_INFO.

Can I get schema-wide size totals?

Sum the size column grouped by schema: SELECT schema, SUM(size) FROM SVV_TABLE_INFO GROUP BY schema;

How often is SVV_TABLE_INFO updated?

The view reflects nearly real-time stats but may lag during heavy loads. For strict auditing, snapshot the view on schedule.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo