Query goal: | Find base tables in case of which toast_tuple_target storage parameter value is not the default value (2040). "Changing this value may not be useful for very short or very long rows. Note that the default setting is often close to optimal, and it is possible that setting this parameter could have negative effects in some cases. " Make sure that the parameter has an optimal value. |
Query type: | General (Overview of some aspect of the database.) |
Query license: | MIT License |
Data source: | INFORMATION_SCHEMA+system catalog |
SQL query: | Click on query to copy it
WITH base_tables AS (SELECT pg_class.oid AS table_oid, pg_class.relname AS table_name, pg_namespace.nspname AS table_schema, unnest(reloptions) AS reloptions FROM pg_catalog.pg_class, pg_catalog.pg_namespace WHERE pg_class.relnamespace = pg_namespace.oid AND relkind='r'), base_tables_fillfactor AS (SELECT table_oid, table_schema, table_name, regexp_replace(reloptions,'[^0-9]','','g')::int AS toast_tuple_target FROM base_tables WHERE table_schema NOT IN (SELECT schema_name FROM INFORMATION_SCHEMA.schemata WHERE schema_name<>'public' AND schema_owner='postgres' AND schema_name IS NOT NULL) AND reloptions ILIKE 'toast_tuple_target%') SELECT table_schema, table_name, toast_tuple_target, (SELECT Count(*) AS cnt FROM pg_attribute AS a WHERE a.attrelid=btf.table_oid AND a.attisdropped = false AND a.attnum>=1) AS number_of_columns FROM base_tables_fillfactor AS btf WHERE toast_tuple_target<>2040 ORDER BY table_schema, table_name; |
Collection name | Collection description |
---|---|
Find problems by overview | Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not . |
Category name | Category description |
---|---|
Data at the database physical level | Queries of this category provide information about the disk usage. |
TOAST | Queries of this category provide information about The Oversized-Attribute Storage Technique. |
Reference |
---|
https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS |