Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A3DA89FB688 for ; Fri, 27 Apr 2007 13:35:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 97257-09 for ; Fri, 27 Apr 2007 13:35:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 7CE3D9FB513 for ; Fri, 27 Apr 2007 13:35:07 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id EF7C714380A; Fri, 27 Apr 2007 17:33:30 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id DFAF4274120; Fri, 27 Apr 2007 17:07:22 +0100 (BST) Message-ID: <46321FBA.3070302@archonet.com> Date: Fri, 27 Apr 2007 17:07:22 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: sid@etsy.com Cc: pgsql-performance@postgresql.org Subject: Re: [Fwd: ] How References: <50431.209.51.183.100.1177687851.squirrel@mailbox.etsy.com> In-Reply-To: <50431.209.51.183.100.1177687851.squirrel@mailbox.etsy.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/475 X-Sequence-Number: 24352 Siddharth Anand wrote: > Hi! > I read the link below and am puzzled by or curious about something. > http://www.postgresql.org/docs/8.1/interactive/datatype-character.html > > The Tip below is intriguing > > "Tip: There are no performance differences between these three types, > apart from the increased storage size when using the blank-padded type. > While character(n) has performance advantages in some other database > systems, it has no such advantages in PostgreSQL. In most situations text > or character varying should be used instead." > > How can a field that doesn't have a limit like "text" perform similarly to > char varying(128), for example? At some point, we need to write data to > disk. The more data that needs to be written, the longer the disk write > will take, especially when it requires finding free sectors to write to. That's no difference *for the same amount of data*. So, char(128), varchar(128) with 128 characters and text with 128 characters in it are the same. This isn't always the case with other systems. > Another interesting quote from the same page is the following: > > "Long values are also stored in background tables so they do not interfere > with rapid access to the shorter column values. " > > If the long values are stored in a separate table, on a different part of > the disk, doesn't this imply an extra disk seek? Won't it therefore take > longer? Yes. But you gain every time you read from the table and aren't interested in that column. Typically large text columns contain descriptive text and aren't used in joins, so it pays for itself quite easily. -- Richard Huxton Archonet Ltd