pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[Fwd: ] How
2+ messages / 2 participants
[nested] [flat]

* [Fwd: ] How
@ 2007-04-27 15:30  Siddharth Anand <sid@etsy.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Siddharth Anand @ 2007-04-27 15:30 UTC (permalink / raw)
  To: pgsql-performance

Hi!
I read the link below and am puzzled by or curious about something.
http://www.postgresql.org/docs/8.1/interactive/datatype-character.html

The Tip below is intriguing

"Tip:  There are no performance differences between these three types,
apart from the increased storage size when using the blank-padded type.
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."

How can a field that doesn't have a limit like "text" perform similarly to
char varying(128), for example? At some point, we need to write data to
disk. The more data that needs to be written, the longer the disk write
will take, especially when it requires finding free sectors to write to.

Another interesting quote from the same page is the following:

"Long values are also stored in background tables so they do not interfere
with rapid access to the shorter column values. "

If the long values are stored in a separate table, on a different part of
the disk, doesn't this imply an extra disk seek? Won't it therefore take
longer?


Sid








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [Fwd: ] How
@ 2007-04-27 16:07  Richard Huxton <dev@archonet.com>
  parent: Siddharth Anand <sid@etsy.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Huxton @ 2007-04-27 16:07 UTC (permalink / raw)
  To: sid@etsy.com; +Cc: pgsql-performance

Siddharth Anand wrote:
> Hi!
> I read the link below and am puzzled by or curious about something.
> http://www.postgresql.org/docs/8.1/interactive/datatype-character.html
> 
> The Tip below is intriguing
> 
> "Tip:  There are no performance differences between these three types,
> apart from the increased storage size when using the blank-padded type.
> 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."
> 
> How can a field that doesn't have a limit like "text" perform similarly to
> char varying(128), for example? At some point, we need to write data to
> disk. The more data that needs to be written, the longer the disk write
> will take, especially when it requires finding free sectors to write to.

That's no difference *for the same amount of data*. So, char(128), 
varchar(128) with 128 characters and text with 128 characters in it are 
the same. This isn't always the case with other systems.

> Another interesting quote from the same page is the following:
> 
> "Long values are also stored in background tables so they do not interfere
> with rapid access to the shorter column values. "
> 
> If the long values are stored in a separate table, on a different part of
> the disk, doesn't this imply an extra disk seek? Won't it therefore take
> longer?

Yes. But you gain every time you read from the table and aren't 
interested in that column. Typically large text columns contain 
descriptive text and aren't used in joins, so it pays for itself quite 
easily.

-- 
   Richard Huxton
   Archonet Ltd



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-04-27 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-27 15:30 [Fwd: ] How Siddharth Anand <sid@etsy.com>
2007-04-27 16:07 ` Richard Huxton <dev@archonet.com>

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