X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 236E6533BE for ; Wed, 23 Mar 2005 11:31:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38824-05 for ; Wed, 23 Mar 2005 11:31:28 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 5C218533B8 for ; Wed, 23 Mar 2005 11:31:27 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) id 1DE42z-000DON-4R; Wed, 23 Mar 2005 11:29:13 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 9BFAF177C5; Wed, 23 Mar 2005 11:31:28 +0000 (GMT) Message-ID: <42415390.8030208@archonet.com> Date: Wed, 23 Mar 2005 11:31:28 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dawid Kuroczko Cc: pgsql-performance@postgresql.org Subject: Re: best practices with index on varchar column References: <200503230402.j2N42ax1022249@mail.census.gov.ph> <758d5e7f05032301351b685c44@mail.gmail.com> In-Reply-To: <758d5e7f05032301351b685c44@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/490 X-Sequence-Number: 11195 Dawid Kuroczko wrote: > On Wed, 23 Mar 2005 12:11:56 +0800, Michael Ryan S. Puncia > wrote: > >>I have an experience using LIKE in a VARCHAR column and select statement >>suffers a lot so I decided to go back in CHAR > According to the PostgreSQL's documentation: > > 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. > > > To my best knowledge char and varchar are stored in a same way > (4-byte length plus textual value), so using char should make tables > bigger in your case. Then again, having each row exactly the same > size makes it easier to delete and then later insert a new row in > a same spot. Am I thinking correct? Is it a case where using char(n) > makes that table avoid hmm fragmentation of some sort? There aren't any noticeable differences between char and varchar. MVCC doesn't overwrite rows anyway, so static size is irrelevant. In any case, PG's toast setup splits out large text fields and compresses them - so it's not that simple. -- Richard Huxton Archonet Ltd