APPLIES TO: Azure Cosmos DB for PostgreSQL (powered by the Citus database extension to PostgreSQL)
The usual way to find table sizes in PostgreSQL, pg_total_relation_size
, drastically under-reports the size of distributed tables on Azure Cosmos DB for PostgreSQL. All this function does on a cluster is to reveal the size of tables on the coordinator node. In reality, the data in distributed tables lives on the worker nodes (in shards), not on the coordinator. A true measure of distributed table size is obtained as a sum of shard sizes. Azure Cosmos DB for PostgreSQL provides helper functions to query this information.
citus_relation_size plus:
citus_table_size plus:
These functions are analogous to three of the standard PostgreSQL object size functions, except if they can't connect to a node, they error out.
ExampleHere's how to list the sizes of all distributed tables:
SELECT logicalrelid AS name,
pg_size_pretty(citus_table_size(logicalrelid)) AS size
FROM pg_dist_partition;
Output:
âââââââââââââââââ¬ââââââââ
â name â size â
âââââââââââââââââ¼ââââââââ¤
â github_users â 39 MB â
â github_events â 37 MB â
âââââââââââââââââ´ââââââââ
Next steps
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4