Updated on 2023-10-31 GMT+08:00

PGXC_GET_TABLE_SKEWNESS

PGXC_GET_TABLE_SKEWNESS displays the data skew on tables in the current database. Only the system administrator or the preset role gs_role_read_all_stats can access this view.

Table 1 PGXC_GET_TABLE_SKEWNESS columns

Name

Type

Description

schemaname

name

Schema name of a table

tablename

name

Name of a table

totalsize

numeric

Total size of a table, in bytes

avgsize

numeric(1000,0)

Average table size (total table size divided by the number of DNs), which is the ideal size of tables distributed on each DN

maxratio

numeric(4,3)

Ratio of the maximum table size on a single DN to the total table size

minratio

numeric(4,3)

Ratio of the minimum table size on a single DN to the total table size

skewsize

bigint

Table skew rate (the maximum table size on a single DN minus the minimum table size on a single DN)

skewratio

numeric(4,3)

Table skew rate (skew size divided by total table size)

skewstddev

numeric(1000,0)

Standard deviation of table distribution (For two tables of the same size, a larger deviation indicates a more severe skew.)

Examples

Run the following command to query the data skews of all tables in the database (the number of tables in the database is less than 10,000):

If the number of tables in the database is more than 10,000, do not use the PGXC_GET_TABLE_SKEWNESS view because it takes a long time (hours) to query the entire database for skewed columns. You are advised to refer to the definition of the PGXC_GET_TABLE_SKEWNESS view and use the table_distribution() function to define the output. This optimizes the calculation by reducing the output columns. An example is shown as follows: