pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedperformance cost for varchar(20), varchar(255), and text
3+ messages / 3 participants
[nested] [flat]
* performance cost for varchar(20), varchar(255), and text
@ 2008-07-05 11:19 Jessica Richard <rjessil@yahoo.com>
2008-07-05 15:04 ` Re: performance cost for varchar(20), varchar(255), and text Lew <lew@lwsc.ehost-services.com>
2008-07-05 16:27 ` Re: performance cost for varchar(20), varchar(255), and text Shane Ambler <pgsql@Sheeky.Biz>
0 siblings, 2 replies; 3+ messages in thread
From: Jessica Richard @ 2008-07-05 11:19 UTC (permalink / raw)
To: pgsql-admin
I am tuning a database created by someone else.
I noticed that some column lengths were defined longer than needed.
For example, an Id column is holding a stand length of 20 characters but was defined as varchar(255).
On some other columns, for example, a Description column is supposed to hold less than 100 characters but defined as text.
I am trying to understand the performance impact if a column is over defined in the following cases:
1. char(20) vs varchar(20)
2. varchar(20) vs varchar(255)
3. varchar(255) vs text
thanks,
Jessica
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: performance cost for varchar(20), varchar(255), and text
2008-07-05 11:19 performance cost for varchar(20), varchar(255), and text Jessica Richard <rjessil@yahoo.com>
@ 2008-07-05 15:04 ` Lew <lew@lwsc.ehost-services.com>
1 sibling, 0 replies; 3+ messages in thread
From: Lew @ 2008-07-05 15:04 UTC (permalink / raw)
To: pgsql-admin
Jessica Richard wrote:
> I am tuning a database created by someone else.
>
> I noticed that some column lengths were defined longer than needed.
>
> For example, an Id column is holding a stand length of 20 characters but
> was defined as varchar(255).
>
> On some other columns, for example, a Description column is supposed to
> hold less than 100 characters but defined as text.
>
> I am trying to understand the performance impact if a column is over
> defined in the following cases:
>
> 1. char(20) vs varchar(20)
>
> 2. varchar(20) vs varchar(255)
>
> 3. varchar(255) vs text
Interestingly, the Postgres documentation has the answer:
<http://www.postgresql.org/docs/8.3/interactive/datatype-character.html;
> Tip: There are no performance differences between these three types, apart
> from increased storage size when using the blank-padded type, and a few extra
> cycles to check the length when storing into a length-constrained column.
> While character(n) has performance advantages in some other database systems,
> it has no such advantages in PostgreSQL. In most situations text or character
> varying should be used instead.
Performance is not the only issue. The semantics of CHAR and VARCHAR differ.
You cannot use them equivalently.
I recommend searching the docs as a first approach to finding such answers.
--
Lew
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: performance cost for varchar(20), varchar(255), and text
2008-07-05 11:19 performance cost for varchar(20), varchar(255), and text Jessica Richard <rjessil@yahoo.com>
@ 2008-07-05 16:27 ` Shane Ambler <pgsql@Sheeky.Biz>
1 sibling, 0 replies; 3+ messages in thread
From: Shane Ambler @ 2008-07-05 16:27 UTC (permalink / raw)
To: Jessica Richard <rjessil@yahoo.com>; +Cc: pgsql-admin
Jessica Richard wrote:
> I am tuning a database created by someone else.
>
> I noticed that some column lengths were defined longer than needed.
>
> For example, an Id column is holding a stand length of 20 characters
> but was defined as varchar(255).
>
> On some other columns, for example, a Description column is supposed
> to hold less than 100 characters but defined as text.
>
> I am trying to understand the performance impact if a column is over
> defined in the following cases:
>
> 1. char(20) vs varchar(20)
>
> 2. varchar(20) vs varchar(255)
>
> 3. varchar(255) vs text
>
>
> thanks, Jessica
>
From the manual -
<quote>
Tip: There are no performance differences between these three types,
apart from increased storage size when using the blank-padded type, and
a few extra cycles to check the length when storing into a
length-constrained column. While character(n) has performance advantages
in some other database systems, it has no such advantages in PostgreSQL.
In most situations text or character varying should be used instead.
</quote>
http://www.postgresql.org/docs/8.3/static/datatype-character.html
--
Shane Ambler
pgSQL (at) Sheeky (dot) Biz
Get Sheeky @ http://Sheeky.Biz
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2008-07-05 16:27 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-07-05 11:19 performance cost for varchar(20), varchar(255), and text Jessica Richard <rjessil@yahoo.com>
2008-07-05 15:04 ` Lew <lew@lwsc.ehost-services.com>
2008-07-05 16:27 ` Shane Ambler <pgsql@Sheeky.Biz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox