pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
please advise on column data type
3+ messages / 3 participants
[nested] [flat]

* please advise on column data type
@ 2002-04-16 01:25 jack <datactrl@tpg.com.au>
  2002-04-16 02:51 ` Re: please advise on column data type Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 3+ messages in thread

From: jack @ 2002-04-16 01:25 UTC (permalink / raw)
  To: pgsql-sql

When I create a table can I always use the rule, use VARCHAR for all
variable length string data and use CHAR for only fixed length string data.
Or I have to consider if the column will be set as an index or primary key,
it would be better to use CHAR for better performance.

JACK




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

* Re: please advise on column data type
  2002-04-16 01:25 please advise on column data type jack <datactrl@tpg.com.au>
@ 2002-04-16 02:51 ` Josh Berkus <josh@agliodbs.com>
  2002-04-16 04:47   ` Re: please advise on column data type Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Josh Berkus @ 2002-04-16 02:51 UTC (permalink / raw)
  To: jack <datactrl@tpg.com.au>; pgsql-sql

Jack,

Please post your questions to PGSQL-NOVICE in the future.  That is the
more appropriate venue for your type of question.  PGSQL-SQL is more
appropriate for advanced SQL questions and arguments about the SQL-92
standard.

> When I create a table can I always use the rule, use VARCHAR for all
> variable length string data and use CHAR for only fixed length string
> data.
> Or I have to consider if the column will be set as an index or
> primary key,
> it would be better to use CHAR for better performance.

In some databases, yes.  However, in PostgreSQL, there is no
performance difference between CHAR, VARCHAR, and TEXT.  So use what's
appropriate for the data being stored.

-Josh Berkus





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

* Re: please advise on column data type
  2002-04-16 01:25 please advise on column data type jack <datactrl@tpg.com.au>
  2002-04-16 02:51 ` Re: please advise on column data type Josh Berkus <josh@agliodbs.com>
@ 2002-04-16 04:47   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2002-04-16 04:47 UTC (permalink / raw)
  To: Josh Berkus <josh@agliodbs.com>; +Cc: jack <datactrl@tpg.com.au>; pgsql-sql

"Josh Berkus" <josh@agliodbs.com> writes:
> In some databases, yes.  However, in PostgreSQL, there is no
> performance difference between CHAR, VARCHAR, and TEXT.  So use what's
> appropriate for the data being stored.

In fact, char() is probably *worse* than the other alternatives, at
least for data that doesn't have a clearly defined length, because
it forces blank-padding on you.

I'd use char(N) for US postal abbreviations (state = char(2), etc)
and not a lot else.  If you have an *error checking* reason to use
char(N), then use it.  If you think you are getting a performance
improvement, then you are far out in left field.

			regards, tom lane



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


end of thread, other threads:[~2002-04-16 04:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-04-16 01:25 please advise on column data type jack <datactrl@tpg.com.au>
2002-04-16 02:51 ` Josh Berkus <josh@agliodbs.com>
2002-04-16 04:47   ` Tom Lane <tgl@sss.pgh.pa.us>

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