How to find the size of a table in Redshift

This is some text inside of a div block.
Published
May 2, 2024
Author

How can you determine the size of a table in Redshift?

To ascertain the size of a table in Redshift, a specific command is utilized. This command is SELECT ``table'', size, tbl_rows FROM SVV_TABLE_INFO. In this command, the 'table' column refers to the table name, 'size' refers to the table size in MB, and 'tbl_rows' is the total number of rows in the table.

  • SVV_TABLE_INFO: This is a Redshift systems table that provides information about user-defined tables in a Redshift database. This table is only visible to superusers.
  • Table Size: The size column in the command represents the size of the table in megabytes.
  • Table Rows: The tbl_rows column in the command indicates the total number of rows in the table.

What is the role of SVV_TABLE_INFO in Redshift?

SVV_TABLE_INFO is a system table in Redshift that contains information about user-defined tables in a Redshift database. It is only visible to superusers and is used to retrieve various details about a table, including its size and the total number of rows.

  • User-defined tables: These are tables created by users in the Redshift database. SVV_TABLE_INFO provides detailed information about these tables.
  • Superuser visibility: Only superusers can view the SVV_TABLE_INFO table. This is a security measure to prevent unauthorized access to table information.
  • Table details: SVV_TABLE_INFO can be used to retrieve various details about a table, such as its size and the total number of rows.

How can you use the table_info.sql script in Redshift?

The table_info.sql script can be used in Redshift to return a list of all user tables in the system, along with information about each table. The 'mbytes' column in the script indicates the total size of each table in megabytes.

  • User Tables: The script returns a list of all user tables in the system, providing a comprehensive overview of the database structure.
  • Table Information: Along with the list of tables, the script also provides detailed information about each table.
  • Mbytes column: This column in the script indicates the total size of each table in megabytes, helping users understand the space utilization of each table.


SELECT "table", size, tbl_rows
FROM SVV_TABLE_INFO

Keep reading

See all