json datatype and table bloat?

From: Gregory Haase <haaseg(at)onefreevoice(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: json datatype and table bloat?
Date: 2013-10-28 23:17:34
Message-ID: CAHA6QFTQ1Wqo+wRz=7fTTPeuDSc-HMFKBEWR84=a5rPqnATQZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table that is triggering my nagios database bloat alert regularly.
Usually, I have to give it the vacuum full more than once to get it under
the threshold. Today I tried repeatedly and cannot get the alert to resolve.

I had a discussion with one of the primary developers about how the table
is utilized, and it turns out they are basically only ever inserting into
it. This sort of flies in the face of conventional wisdom about bloat being
caused by frequent updates and deletes.

We were looking at it, and one of the things that struck me is that this
table has a column with a json datatype. I looked through
information_schema.columns and there is only one other table with a json
datatype, and I recall having bloat issues with this table in the past as
well.

I'm wondering if the json datatype is just naturally more bloated than
other types, or if the query in the check_postgresql.pl nagios script is
not accurate, or if maybe my thresholds are simply too low?

The table design itself is pretty simple:
id | integer | not null default nextval('
table_schema.table_name_id_seq'::regclass)
type | character varying(255) |
criteria | json |
created_at | timestamp without time zone | not null
updated_at | timestamp without time zone | not null
Indexes:
"table_name_pkey" PRIMARY KEY, btree (id)

The nagios output looks like this (sanitized):
POSTGRES_BLOAT WARNING: DB "db_name" (host:host.domain.com) (db db_name)
table table_schema.table_name rows:29305 pages:1733 shouldbe:330 (5.3X)
wasted size:11493376 (10 MB)

Thoughts?

Greg Haase

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Perry Smith 2013-10-28 23:36:34 Re: Cursor Example Needed
Previous Message John R Pierce 2013-10-28 23:13:01 Re: Cursor Example Needed