Re: Compressed binary field

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Edson Richter" <edsonrichter(at)hotmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Compressed binary field
Date: 2012-09-12 18:09:49
Message-ID: 5050899D020000250004A2CB@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edson Richter <edsonrichter(at)hotmail(dot)com> wrote:

> SELECT pg_size_pretty(pg_database_size('mydatabase'));
> pg_size_pretty
> ----------------
> 7234 MB

> SELECT nspname || '.' || relname AS "relation",
> pg_size_pretty(pg_relation_size(C.oid)) AS "size"
> FROM pg_class C
> LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
> WHERE nspname NOT IN ('pg_catalog', 'information_schema')
> ORDER BY pg_relation_size(C.oid) DESC
> LIMIT 10;
> relation | size
> ---------------------------------+---------
> pg_toast.pg_toast_18409 | 4976 MB
> pg_toast.pg_toast_18146 | 290 MB
> [ ... ]

> SELECT relkind, oid, relfilenode, reltoastrelid,
> relpages, reltuples
> FROM pg_class
> ORDER BY relpages DESC
> LIMIT 10;
>
> results
> relkind | oid | relfilenode | reltoastrelid | relpages |
> reltuples
>
---------+--------+-------------+---------------+----------+------
> -----
> r | 18064 | 18064 | 18086 | 29332 |
> 639639
> r | 18179 | 18179 | 0 | 22797 |
> 1.811e+06
> r | 18116 | 18116 | 18121 | 19772 |
> 724370
> r | 18343 | 18343 | 18347 | 14311 |
> 928633
> r | 18352 | 18352 | 0 | 10488 |
> 917134
> r | 18092 | 18092 | 0 | 7691 |
> 640709
> r | 18396 | 18396 | 18404 | 7670 |
> 172791
> r | 18558 | 18558 | 0 | 7608 |
> 386907
> i | 747805 | 747805 | 0 | 6976 |
> 1.811e+06
> r | 18409 | 18409 | 18413 | 6684 |
> 715084

When I run that query on a big database here, my top three entries
are for relkind of 't' (starting with a 2TB TOAST table for our
document images) and number four is a TOAST index. It's hard to see
why you don't have TOAST entries at the top of your list. Instead
of a VACUUM FULL, could you try a VACUUM FREEZE VERBOSE ANALYZE
against the full database (using a database superuser login) and
capture the output? Please post the portion of the output for the
big table and its TOAST table, and see whether the numbers
(pg_class.relpages * 8KB versus pg_relation_size()) start to match
up.

You might also want to confirm that neither pg_stat_activity nor
pg_prepared_xacts shows any lingering transactions started more than
a few minutes ago.

> So, all of this information was get using unique database session,
> so they must related to same database and data files

Thanks, that helps suggest where to look next.

-Kevin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Henry C. 2012-09-12 18:12:48 9.0 to 9.2 pg_upgrade pain due to collation mismatch
Previous Message Edson Richter 2012-09-12 17:21:52 Re: Compressed binary field