This content applies to a previous version of CARTO
In October 2021 we released a new version of our platform. You can find the latest documentation at docs.carto.com
How to Find the Size of a Dataset
Learn how to use PostgreSQL to find the exact size of a dataset in your CARTO account.
Overview
The Datasets Dashboard provides a size estimate for datasets, but this doesn’t account for additional system elements. PostgreSQL enables you to determine the precise size including TOAST tables and indexes.
Quick Query
To find the total size of a dataset, open it from your Datasets Dashboard, switch to SQL mode, and run:
SELECT pg_size_pretty (pg_total_relation_size('your_dataset_name'))
Detailed Breakdown Query
For a comprehensive size analysis, use this query. Replace your_account_name_or_public with your account name (Enterprise clients) or 'public' (others):
SELECT table_name,
row_estimate,
pg_size_pretty(total_bytes) AS total_size,
pg_size_pretty(index_bytes) AS index_size,
pg_size_pretty(toast_bytes) AS toast_size,
pg_size_pretty(table_bytes) AS dataset_size
FROM (
SELECT *,
total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes
FROM (
SELECT c.oid,
nspname AS table_schema,
relname AS table_name,
c.reltuples AS row_estimate,
pg_total_relation_size(c.oid) AS total_bytes,
pg_indexes_size(c.oid) AS index_bytes,
pg_total_relation_size(reltoastrelid) AS toast_bytes
FROM pg_class c
LEFT JOIN pg_namespace n
ON n.oid = c.relnamespace
WHERE relkind = 'r'
AND nspname like 'your_account_name_or_public'
AND relname = 'your_dataset_name'
) a
) a
ORDER BY total_bytes DESC
Results
This query returns a data view displaying:
- Dataset name and row count
- Original dataset size
- Index size
- TOAST size
- Total size (all components combined)
