How to find and export your PostgreSQL data.
PostgreSQL reports size through SQL functions, not a settings page. Run SELECT pg_size_pretty(pg_database_size(current_database())); as any user with CONNECT on the database and report the total in GB. On Amazon RDS or Cloud SQL the console also shows storage, but that figure includes logs and free space.
Where PostgreSQL shows how much you have.
- Connect with psql or your SQL client as a user that has CONNECT on each database (granted by default) or membership in the pg_read_all_stats role.
- List every database and its size on disk:
SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database WHERE datistemplate = false ORDER BY pg_database_size(datname) DESC; - Inside each database, list the largest tables. pg_total_relation_size includes indexes and TOAST data, and pg_table_size leaves indexes out:
SELECT relname, pg_size_pretty(pg_total_relation_size(relid)) AS total, pg_size_pretty(pg_table_size(relid)) AS without_indexes FROM pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC LIMIT 20; - Get row counts.
SELECT relname, n_live_tup FROM pg_stat_user_tables ORDER BY n_live_tup DESC;gives estimates. For an exact figure on a key table, runSELECT count(*) FROM orders; - Find the oldest record in your core tables using their timestamp column, for example
SELECT min(created_at) FROM orders; - On a managed host, cross-check in the console. For Amazon RDS, the FreeStorageSpace metric in CloudWatch shows free space against the storage you allocated. For Cloud SQL, open the instance's Overview page, which charts storage usage.
Plan and role. No paid plan or admin role is needed. pg_database_size requires CONNECT on the database, which is granted by default, or the pg_read_all_stats role; console figures on Amazon RDS or Cloud SQL require access to that cloud account.
What to report on the Polyshares intake.
Report PostgreSQL in GB. The intake also asks how many years the company has used it and how many seats it has.
On the Polyshares intake, report the sum of pg_database_size across your production databases in GB. This is disk usage. It includes indexes, TOAST data and dead rows that vacuum has not yet cleared, so it is larger than the raw rows. pg_size_pretty uses powers of 1024, so its GB is a gibibyte.
Do not report allocated storage from Amazon RDS or Cloud SQL. Allocated storage is what you provisioned, and used disk on the instance also holds transaction logs and replication slot files. Read replicas and backups are copies, so count the primary only.
For years in use, take the earliest created_at or similar timestamp in your core tables. If tables have no timestamps, use the date the instance was created. For seats, count the application users or customer accounts the database records, such as rows in a users or accounts table, not database roles.
Export the full history.
- Where you can, run the export against a read replica so the primary carries no extra read load. On Amazon RDS for PostgreSQL, a read replica is a read-only copy kept current with native PostgreSQL replication.
- Dump each database in directory format with parallel jobs:
pg_dump -Fd -j 4 -f /backup/mydb_dir -d mydb. Directory format is compressed by default and is the only format that supports -j. - If you prefer one file per database, use custom format instead:
pg_dump -Fc -f mydb.dump -d mydb. Both directory and custom dumps restore with pg_restore. - Export roles and tablespaces, which pg_dump leaves out:
pg_dumpall --globals-only -f globals.sql. To write every database in the cluster to one plain SQL script instead, runpg_dumpall -f cluster.sql. - On Cloud SQL you can also export a SQL dump to a Cloud Storage bucket:
gcloud sql export sql INSTANCE_NAME gs://BUCKET_NAME/mydb.gz --database=mydb --offload. The --offload flag runs a serverless export that reduces load on the instance, at extra cost.
pg_dump exports one database at a time and does not include cluster-wide objects such as roles and tablespaces; use pg_dumpall for those. pg_dump makes a consistent copy while the database is in use and does not block other readers or writers.
Plain format (-Fp) is an SQL script with no compression unless you add -Z. Custom and directory formats are compressed with gzip by default, and tar format does not support compression. Only directory format supports parallel dumps with -j, and parallel dumps from a standby need PostgreSQL 10 or later.
A dump holds live rows and index definitions, not index contents or dead rows, so it is usually much smaller than pg_database_size. Data in unlogged tables is always excluded when you dump from a standby server.
Cloud SQL exports use pg_dump and write to Cloud Storage. The Cloud SQL service account needs the storage.objectAdmin role on the bucket, and Google recommends keeping at least 25 percent of the database size free on the instance before exporting.
The intake only needs the size, so you do not have to run an export to fill it in. You also do not need to clean or scrub an export. Polyshares handles anonymization before anything moves.
Why PostgreSQL data has value for AI training.
A production PostgreSQL database is usually the system of record: accounts, orders, tickets, shipments, payments and every status change between them. Foreign keys link those rows, so one customer's history can be followed across tables with exact timestamps.
That joined structure is hard to rebuild from any other source. It shows what happened, in what order and with what result, which makes it useful for training and evaluating models that must reason over real business processes.
What stays private.
You choose which schemas and tables leave the database, and pg_dump --exclude-table keeps tables such as credentials, payment tokens or audit logs out of the dump.
We anonymize identifying details before anything moves. Polyshares does that work, so your team does not have to scrub records first.
Your company keeps ownership of its data. The license is bounded to defined material and a defined use.
Polyshares is the buyer and pays your company directly. There is no fee or commission, and Polyshares reviews the record before it makes any offer.
Common questions about PostgreSQL data.
Why is pg_database_size so much larger than my dump file?
pg_database_size measures disk space, including indexes, TOAST data and dead rows waiting for vacuum. A dump contains live rows and index definitions only, and custom or directory formats are compressed. A dump several times smaller than the database is normal.
Will pg_dump lock or slow down my production database?
pg_dump does not block other users who read or write. It does add read load for as long as the dump runs, so for large databases point it at a read replica or run it during a quiet period.
Does pg_dump include database users and passwords?
No. Roles are cluster-wide objects and pg_dump exports a single database. pg_dumpall --globals-only exports them if you need them, but database roles are not part of the data Polyshares licenses.
Can I export from Amazon RDS for PostgreSQL without touching the primary?
Yes. Create a read replica, which is read-only and kept current by PostgreSQL replication, and run pg_dump against the replica endpoint. If you run a parallel dump on the replica, use PostgreSQL 10 or later.
Source: PostgreSQL documentation: Database object size functions, PostgreSQL documentation: pg_dump, Amazon RDS: Working with read replicas for RDS for PostgreSQL, Cloud SQL for PostgreSQL: Export and import using SQL dump files. Checked September 2026.
Related
- MySQLSum data_length plus index_length from information_schema, export with mysqldump
- BigQueryTABLE_STORAGE logical bytes for size, EXPORT DATA or bq extract to Cloud Storage
- SnowflakeCost management and TABLE_STORAGE_METRICS for size, COPY INTO a stage to export
- Amazon S3Storage Lens and BucketSizeBytes for size, aws s3 sync or Batch Operations to export
- Amazon RedshiftSVV_TABLE_INFO size in 1 MB blocks, UNLOAD to Amazon S3 as Parquet
- DatabricksDESCRIBE DETAIL sizeInBytes per Delta table, export by cloning to your cloud storage
- MongoDBdb.stats() dataSize versus storageSize, full export with mongodump
- Amazon DynamoDBItem count and table size per table, export to Amazon S3 with PITR turned on
- All data source guidesEvery system on the Polyshares intake, grouped by category.
Put your numbers on the intake.
List your systems, their sizes and your headcount in one intake. Polyshares reviews the record and prices it. There is no fee or commission to your company.
Check your data