Re: VARCHAR -vs- CHAR: huge performance difference?

From: "C(dot) Bensend" <benny(at)bennyvision(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: VARCHAR -vs- CHAR: huge performance difference?
Date: 2004-06-16 01:31:56
Message-ID: 55909.63.227.74.41.1087349538.squirrel@webmail.stinkweasel.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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"

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2004-06-16 01:39:23 Re: Out of memory error
Previous Message Scott Marlowe 2004-06-16 01:23:06 Re: VARCHAR -vs- CHAR: huge performance difference?