X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EEECED1D09C for ; Thu, 8 Apr 2004 14:50:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34755-05 for ; Thu, 8 Apr 2004 14:50:46 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3CCA4D1D09A for ; Thu, 8 Apr 2004 14:50:45 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i38HnNWc015733; Thu, 8 Apr 2004 13:49:24 -0400 (EDT) To: "Tony and Bryn Reina" Cc: "Stephan Szabo" , pgsql-admin@postgresql.org Subject: Re: Database storage bloat In-reply-to: References: <272e4be7.0404080115.39f1cb36@posting.google.com> <20040408063838.Q93611@megazone.bigpanda.com> Comments: In-reply-to "Tony and Bryn Reina" message dated "Thu, 08 Apr 2004 17:49:26 +0200" Date: Thu, 08 Apr 2004 13:49:23 -0400 Message-ID: <15732.1081446563@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/159 X-Sequence-Number: 13132 "Tony and Bryn Reina" 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