[GENERAL] column type varchar(128) not null default '' vs varchar(128)

2006-03-08 Thread Emi Lu

Hello,

When setuping column types, is there the big efficiency difference 
between the following two examples?


col  varchar(128) NOT NULL default ''
   vs.
col  varchar(128)


Thanks a lot,
Ying



---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] column type varchar(128) not null default '' vs varchar(128)

2006-03-08 Thread Dann Corbit
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:pgsql-general-
 [EMAIL PROTECTED] On Behalf Of Emi Lu
 Sent: Wednesday, March 08, 2006 2:52 PM
 To: pgsql-general@postgresql.org
 Subject: [GENERAL] column type varchar(128) not null default '' vs
 varchar(128)
 
 Hello,
 
 When setuping column types, is there the big efficiency difference
 between the following two examples?
 
 col  varchar(128) NOT NULL default ''
 vs.
 col  varchar(128)

The difference has nothing to do with efficiency and everything to do
with what goes into them.

The first example does not allow col to be NULL.  If you insert a row
and do not insert any data into column col, col will get a value of ''
(empty) which is not the same thing as NULL.

The second example does not have a default and allows NULL values.  So
if you insert data into the table in the second example, and you do not
provide data for column col, then col will be NULL.

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match