X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 161E9D1B8EF for ; Wed, 20 Aug 2003 14:18:14 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25631-04 for ; Wed, 20 Aug 2003 14:18:04 -0300 (ADT) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 5F581D1BABA for ; Wed, 20 Aug 2003 14:18:02 -0300 (ADT) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.6) with ESMTP-TLS id 35511; Wed, 20 Aug 2003 09:35:26 -0700 Message-ID: <3F43ABBB.20405@joeconway.com> Date: Wed, 20 Aug 2003 10:11:23 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stephan Szabo Cc: Brian McCane , pgsql-admin@postgresql.org Subject: Re: Compression of text fields References: <20030820092151.H8293-100000@megazone.bigpanda.com> In-Reply-To: <20030820092151.H8293-100000@megazone.bigpanda.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/228 X-Sequence-Number: 9949 Stephan Szabo wrote: > On Wed, 20 Aug 2003, Brian McCane wrote: >> 4) Can I disable the compression to improve storage speed >> if the compression algorithm is not as good as deflate > > See ALTER TABLE ALTER COLUMN SET STORAGE (I would guess you would want > external, but I'm not 100% sure, check the docs :) ) Yes, EXTERNAL is correct. We had a good thread on this topic on PERFORM a couple of weeks ago. Starts here: http://archives.postgresql.org/pgsql-performance/2003-08/msg00030.php Ends here: http://archives.postgresql.org/pgsql-performance/2003-08/msg00144.php Note the issue with UPDATE in place of the data. You need to concatenate an empty string to force the change of storage. > Also, I'm not sure if storing a compressed version in a text field is a > good idea. I'd think that bytea would be a better match. > You can pretty much guarantee problems if you store binary (i.e. pre-compressed) data in a text field. If your uncompressed data is not binary, you should probably do one of these options: 1) pre-compress and store in a bytea field with storage set to EXTERNAL 2) store as-is in a text field and let Postgres do the compression for you 3) store as-is in a text field with storage set to EXTERNAL Personally, I'd use #3 if you consider disk space cheap and performance important, or #2 if you really need the data compressed. You might get moderately better compression using an external program, but it is probably at a big performance hit. HTH, Joe