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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: VARCHAR -vs- CHAR: huge performance difference?
Дата
Msg-id 15549.1087351669@sss.pgh.pa.us
обсуждение исходный текст
Ответ на VARCHAR -vs- CHAR: huge performance difference?  ("C. Bensend" <benny@bennyvision.com>)
Ответы Re: VARCHAR -vs- CHAR: huge performance difference?  ("C. Bensend" <benny@bennyvision.com>)
Список pgsql-admin
"C. Bensend" <benny@bennyvision.com> writes:
> So, I went ahead and created an exact copy of this table, with the
> exception of creating all character columns as type char(), not varchar().
> I was pondering if making PostgreSQL worry about the varying lengths
> by using varchar was the problem...

The above transformation is a guaranteed loser in Postgres.

>    And sure enough, counting the rows on the new table takes around
> 148ms.  That's a pretty big difference from 3600ms.

I'm betting that the original table is physically huge because you've
not vacuumed it regularly.  The copying produced a table with no wasted
space, so physically smaller even though the live data is noticeably
bigger (because of all the padding blanks you forced to be added).

Check what VACUUM VERBOSE has to say about each of these tables...

            regards, tom lane

В списке pgsql-admin по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Out of memory error
Следующее
От: "C. Bensend"
Дата:
Сообщение: Re: VARCHAR -vs- CHAR: huge performance difference?