Why does the unsorted column have NULL values in SVV_TABLE_INFO in Amazon Redshift?

1 minute read
0

When I query SVV_TABLE_INFO in Amazon Redshift, the unsorted column has NULL values instead of percentage values.

Short Description

The SVV_TABLE_INFO view shows summary information for tables in Amazon Redshift.

When you create a table and select the AUTO sort key option, Amazon Redshift doesn't assign an initial sort key. If Amazon Redshift query optimizer determines that a sort key improves query performance, then it might automatically change the sort key for your table.

Amazon Redshift tracks the percentage of unsorted rows only in tables that specify a sort key. If your table lacks a defined sort key, then Amazon Redshift assigns a NULL value to unsorted rows.

Resolution

To obtain the sorting statistics for your table, define a sort key.

To include a sort key for an existing table, run the following ALTER TABLE command:

ALTER TABLE table_name ALTER SORTKEY (column1, column2);

Note: Replace table_name with the name of your table.

To create a table with an AUTO sort key, use the following command:

ALTER TABLE table_name ALTER SORTKEY AUTO;

Note: Replace table_name with the name of your table.

AWS OFFICIALUpdated 13 days ago