X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8712BD1B1BE for ; Tue, 15 Jun 2004 22:32:24 -0300 (ADT) 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 13432-10 for ; Wed, 16 Jun 2004 01:32:19 +0000 (GMT) Received: from fusion.bennyvision.com (fusion.bennyvision.com [216.161.119.28]) by svr1.postgresql.org (Postfix) with SMTP id 009CCD1B1B4 for ; Tue, 15 Jun 2004 22:32:14 -0300 (ADT) Received: (qmail 8834 invoked from network); 16 Jun 2004 01:32:18 -0000 Received: from localhost (HELO webmail.stinkweasel.net) (127.0.0.1) by fusion.bennyvision.com with SMTP; 16 Jun 2004 01:32:18 -0000 Received: from 63.227.74.41 (SquirrelMail authenticated user benny) by webmail.stinkweasel.net with HTTP; Tue, 15 Jun 2004 20:31:56 -0500 (CDT) Message-ID: <55909.63.227.74.41.1087349538.squirrel@webmail.stinkweasel.net> In-Reply-To: <1087348985.1582.18.camel@localhost.localdomain> References: <51429.63.227.74.41.1087347504.squirrel@webmail.stinkweasel.net> <1087348985.1582.18.camel@localhost.localdomain> Date: Tue, 15 Jun 2004 20:31:56 -0500 (CDT) Subject: Re: VARCHAR -vs- CHAR: huge performance difference? From: "C. Bensend" To: pgsql-admin@postgresql.org User-Agent: SquirrelMail/1.4.2 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME X-Spam-Level: X-Archive-Number: 200406/189 X-Sequence-Number: 13849 > Were those fields populated just like the varchar fields? If not, then > the test proves little. If so, I find it hard to believe that char(x) > would be any faster than varchar. They're all handled about the same. Hi Scott, Yes, the new table was populated from the data from the original, via a: INSERT INTO emails2 SELECT * FROM emails; This should be correct, yes? > If you want to do count(*) on the table, do it by having a table with > nothing but IDs in it that is referenced by the table with all the > text. PostgreSQL can't really optimized aggregate functions with > indexes, so it always winds up doing seq scans. I have also tried doing a count(column) on the emails table, using a column that is indexed. It showed no improvement - I would have expected at least a little gain. And here's the clincher - when I do a count(*) on a different table with the same number of rows but only four varchar columns, it returns the result in 75ms. (!!!) Benny -- "Oh, the Jedis are going to feel this one!" -- Professor Farnsworth, "Futurama"