![]() ![]() SELECT pg_size_pretty(pg_relation_size('article_details')) Use the pg_size_pretty() with the pg_relation_size() function to get the table size in user-friendly formats, such as KBs, MBs, etc. Step 4: Get Table in User-friendly Format The output snippet shows that the pg_relation_size retrieves the size of the “article_details” table. To get the size of the selected table, you must use the “pg_relation_size()” function as follows: SELECT pg_relation_size('article_details') Suppose we need to calculate the size of the “article_details” table. Once you are connected to a database of your choice, run the “\dt” command to describe the list of relations: \dt We are successfully connected to the “example” database. Let’s make a connection with a specific database from the available list: \c example ![]() This particular example is going to elaborate the basic concept of the pg_relation_size() function via stepwise instructions:Įxecute the “\l” command from SQL Shell to get the list of all the databases: \l Here, tab_name is the targeted table whose size needs to be calculated.Įxample: How to Find the Table’s Size in Postgres Using pg_relation_size()? The below syntax is exercised in Postgres to calculate the size of a particular table: pg_relation_size(tab_name) This blog post will demonstrate a couple of functions to calculate the table’s size using practical examples. In addition to this, PostgreSQL offers another handy built-in function named pg_size_pretty() that retrieves the table size in an easily understandable format. If we talk about the table’s size, it can be calculated using the inbuilt pg_relation_size() function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |