Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created March 5, 2014 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnorman/9363985 to your computer and use it in GitHub Desktop.
Save pnorman/9363985 to your computer and use it in GitHub Desktop.
toast query snippet

We can use a varient of the pg_class disk usage queries to find how much space is used by the toast tables for each of the rendering tables.

SELECT mains.relname, 
    toasts.relpages::bigint*8192 AS "toast size", toasts.reltuples AS "toast tuples", indexes.relpages::bigint*8192 AS "toast index size"
  FROM pg_class toasts
    JOIN pg_class mains ON (toasts.oid = mains.reltoastrelid)
    LEFT JOIN pg_class indexes ON (indexes.oid = toasts.reltoastidxid)
  WHERE 
    mains.relname IN ('planet_osm_point', 'planet_osm_line', 'planet_osm_polygon');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment