pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedText/Varchar performance...
5+ messages / 4 participants
[nested] [flat]
* Text/Varchar performance...
@ 2005-10-05 18:21 Cristian Prieto <cristian@clickdiario.com>
2005-10-05 18:34 ` Re: Text/Varchar performance... Steinar H. Gunderson <sgunderson@bigfoot.com>
2005-10-05 19:00 ` Re: [PERFORM] Text/Varchar performance... Josh Berkus <josh@agliodbs.com>
2005-10-10 11:28 ` Re: Text/Varchar performance... Ahmad Fajar <gendowo@konphalindo.or.id>
0 siblings, 3 replies; 5+ messages in thread
From: Cristian Prieto @ 2005-10-05 18:21 UTC (permalink / raw)
To: pgsql-general@postgresql.org; pgsql-performance
Hello, just a little question, It's preferable to use Text Fields or
varchar(255) fields in a table? Are there any performance differences in the
use of any of them?
Thanks a lot for your answer!
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Text/Varchar performance...
2005-10-05 18:21 Text/Varchar performance... Cristian Prieto <cristian@clickdiario.com>
@ 2005-10-05 18:34 ` Steinar H. Gunderson <sgunderson@bigfoot.com>
2 siblings, 0 replies; 5+ messages in thread
From: Steinar H. Gunderson @ 2005-10-05 18:34 UTC (permalink / raw)
To: pgsql-performance
On Wed, Oct 05, 2005 at 12:21:35PM -0600, Cristian Prieto wrote:
> Hello, just a little question, It's preferable to use Text Fields or
> varchar(255) fields in a table? Are there any performance differences in the
> use of any of them?
They are essentially the same. Note that you can have varchar without length
(well, up to about a gigabyte or so after compression), and you can have
varchar with a length well above 255 (say, 100000).
/* Steinar */
--
Homepage: http://www.sesse.net/
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PERFORM] Text/Varchar performance...
2005-10-05 18:21 Text/Varchar performance... Cristian Prieto <cristian@clickdiario.com>
@ 2005-10-05 19:00 ` Josh Berkus <josh@agliodbs.com>
2 siblings, 0 replies; 5+ messages in thread
From: Josh Berkus @ 2005-10-05 19:00 UTC (permalink / raw)
To: pgsql-performance; +Cc: Cristian Prieto <cristian@clickdiario.com>; pgsql-general@postgresql.org
Cristian,
> Hello, just a little question, It's preferable to use Text Fields or
> varchar(255) fields in a table? Are there any performance differences in
> the use of any of them?
TEXT, VARCHAR, and CHAR use the same underlying storage mechanism. This
means that TEXT is actually the "fastest" since it doesn't check length or
space-pad. However, that's unlikely to affect you unless you've millions
of records; you should use the type which makes sense given your
application.
For "large text fields" I always use TEXT. BTW, in PostgreSQL VARCHAR is
not limited to 255; I think we support up to 1GB of text or something
preposterous.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Text/Varchar performance...
2005-10-05 18:21 Text/Varchar performance... Cristian Prieto <cristian@clickdiario.com>
@ 2005-10-10 11:28 ` Ahmad Fajar <gendowo@konphalindo.or.id>
2005-10-10 12:54 ` Re: Text/Varchar performance... Steinar H. Gunderson <sgunderson@bigfoot.com>
2 siblings, 1 reply; 5+ messages in thread
From: Ahmad Fajar @ 2005-10-10 11:28 UTC (permalink / raw)
To: 'Cristian Prieto' <cristian@clickdiario.com>; +Cc: pgsql-performance
Dear Cristian,
If you need to index the field, you must know that it limit the length up to
1000 bytes. So if you need to index the field you must limit the field type,
ex: varchar(250), than you can index the field and you can gain better
perfomance in searching base on the fields, because the search uses the
index you have been created.
If you do not need to index the field, you can use the text field. Because
text field can store data up to 4 Gbytes.
Regards,
ahmad fajar
-----Original Message-----
From: pgsql-performance-owner@postgresql.org
[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Cristian Prieto
Sent: Kamis, 06 Oktober 2005 1:22
To: pgsql-general@postgresql.org; pgsql-performance@postgresql.org
Subject: [PERFORM] Text/Varchar performance...
Hello, just a little question, It's preferable to use Text Fields or
varchar(255) fields in a table? Are there any performance differences in the
use of any of them?
Thanks a lot for your answer!
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Text/Varchar performance...
2005-10-05 18:21 Text/Varchar performance... Cristian Prieto <cristian@clickdiario.com>
2005-10-10 11:28 ` Re: Text/Varchar performance... Ahmad Fajar <gendowo@konphalindo.or.id>
@ 2005-10-10 12:54 ` Steinar H. Gunderson <sgunderson@bigfoot.com>
0 siblings, 0 replies; 5+ messages in thread
From: Steinar H. Gunderson @ 2005-10-10 12:54 UTC (permalink / raw)
To: pgsql-performance
On Mon, Oct 10, 2005 at 06:28:23PM +0700, Ahmad Fajar wrote:
> than you can index the field and you can gain better
> perfomance in searching base on the fields, because the search uses the
> index you have been created.
That really depends on the queries. An index will help some queries (notably
<, = or > comparisons, or LIKE 'foo%' with the C locale), but definitely not
all (it will help you nothing for LIKE '%foo%').
> If you do not need to index the field, you can use the text field. Because
> text field can store data up to 4 Gbytes.
So can varchar.
/* Steinar */
--
Homepage: http://www.sesse.net/
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2005-10-10 12:54 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-05 18:21 Text/Varchar performance... Cristian Prieto <cristian@clickdiario.com>
2005-10-05 18:34 ` Steinar H. Gunderson <sgunderson@bigfoot.com>
2005-10-05 19:00 ` Josh Berkus <josh@agliodbs.com>
2005-10-10 11:28 ` Ahmad Fajar <gendowo@konphalindo.or.id>
2005-10-10 12:54 ` Steinar H. Gunderson <sgunderson@bigfoot.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