Re: VARCHAR -vs- CHAR: huge performance difference? - Mailing list pgsql-admin

From C. Bensend
Subject Re: VARCHAR -vs- CHAR: huge performance difference?
Date
Msg-id 55909.63.227.74.41.1087349538.squirrel@webmail.stinkweasel.net
Whole thread Raw
In response to Re: VARCHAR -vs- CHAR: huge performance difference?  ("Scott Marlowe" <smarlowe@qwest.net>)
List pgsql-admin
> 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"

pgsql-admin by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: VARCHAR -vs- CHAR: huge performance difference?
Next
From: Tom Lane
Date:
Subject: Re: Out of memory error