From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tony and Bryn Reina <reina_ga@hotmail.com>
Cc: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Database storage bloat
Date: Thu, 08 Apr 2004 13:49:23 -0400
Message-ID: <15732.1081446563@sss.pgh.pa.us> (raw)
In-Reply-To: <BAY8-DAV48dqvhu1NQJ0001f557@hotmail.com>
References: <272e4be7.0404080115.39f1cb36@posting.google.com>
<20040408063838.Q93611@megazone.bigpanda.com>
<BAY8-DAV48dqvhu1NQJ0001f557@hotmail.com>
"Tony and Bryn Reina" <reina_ga@hotmail.com> writes:
> CREATE TABLE SegmentValues (
> dbIndex integer REFERENCES EntityFile (dbIndex),
> dwunitid smallint,
> dwsampleindex smallint,
> dtimestamp float4,
> dvalue float4,
> PRIMARY KEY (dbIndex, dtimestamp, dwsampleindex, dwunitid)
> );
> I suppose one thing the binary flat file may be doing is not including the
> time stamp in table SegmentValues. Since I know the sampling rate, I can
> just calculate the timestamp on the fly by the rate times the index
> (assuming no time offset). That would lose a float4 field, but would add
> back a smallint field to the table.
That won't buy you anything at all --- the two bytes saved would be lost
again to alignment padding. (I'm assuming you're on PC hardware with
MAXALIGN = 4 bytes.)
I don't see orders-of-magnitude bloat here though. You've got 16 bytes
of useful data per row (which I suppose was 12 bytes in the flat file?).
There will be 28 bytes of overhead per table row. In addition the index
will require 12 data bytes + 12 overhead bytes per entry; allowing for
the fact that b-tree only likes to pack pages about 2/3ds full, we could
estimate index size as about 36 bytes per original row, giving an
aggregate bloat factor of 6.67X compared to a binary flat file if the
flat file needed 12 bytes per row.
The only way I could see to get to a 65X bloat factor would be if you'd
repeatedly updated the table rows without vacuuming.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, reina_ga@hotmail.com, sszabo@megazone.bigpanda.com
Subject: Re: Database storage bloat
In-Reply-To: <15732.1081446563@sss.pgh.pa.us>
References: <272e4be7.0404080115.39f1cb36@posting.google.com> <20040408063838.Q93611@megazone.bigpanda.com> <BAY8-DAV48dqvhu1NQJ0001f557@hotmail.com> <15732.1081446563@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox