Re: Datatypes and performance - Mailing list pgsql-general

From Maksim Likharev
Subject Re: Datatypes and performance
Date
Msg-id 56510AAEF435D240958D1CE8C6B1770A016D2D8F@mailc03.aurigin.com
Whole thread Raw
In response to Datatypes and performance  ("Jay O'Connor" <joconnor@cybermesa.com>)
Responses Re: Datatypes and performance  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: Datatypes and performance  (Dennis Björklund <db@zigo.dhs.org>)
List pgsql-general
Ok, then if I store 4K - 1byte in a varchar and after that 4K + 1 byte,
and again and again, you are saying me that my text will be jerking
around 2 tables?
So in reality no performance degradation/benefits for varchar vs text,
should be read as 'varchar as slow as text' or keep you varchar under 4K
if you want to read it fast.

Pretty useful detail, thank you.



-----Original Message-----
From: Alvaro Herrera [mailto:alvherre@dcc.uchile.cl]
Sent: Friday, July 04, 2003 2:54 PM
To: Maksim Likharev
Cc: PostgreSQL List
Subject: Re: [GENERAL] Datatypes and performance


On Fri, Jul 04, 2003 at 02:22:39PM -0700, Maksim Likharev wrote:
> Ok, what I see here tells me that text is slower then fixed len
varchar,
> due to stored in separate table ( but how else you can store long
fields
> ).
> so postgres has to read another page(s) in order to get long value.

That's regardless of the datatype: a varchar longer than 2 KiB IIRC will
be stored in a separate table, just as a text longer than 2 KiB.
There's no difference _at all_ for those two datatypes _except_ that the
former is checked for maximum length.  If you store 256 chars in a TEXT
field it will be in the main table as it were a varchar(256).

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Nunca confiaré en un traidor.  Ni siquiera si el traidor lo he creado
yo"
(Barón Vladimir Harkonnen)

pgsql-general by date:

Previous
From: nolan@celery.tssi.com
Date:
Subject: Tables larger than 1GB
Next
From: Alvaro Herrera
Date:
Subject: Re: Datatypes and performance