Thread: Re: Field Size

Re: Field Size

From
"Somasekhar Bangalore"
Date:

There is no harm in having a field size of 1000 character provided u use the proper datatype. Don’t user char(1000). Try using varchar(1000).

 

For character data it is recommended to use the VARCHAR type, since PostgreSQL manages it very well.  On the contrary, if you use the CHAR datatype, the size you specify for the string is pre-allocated in the pages and you allocate space which may not be used.  So your database is bigger than what it should be and performance is lowered, because this way you need more I/O to read the data.

 

Som

 

-----Original Message-----
From: Ganesan Kanavathy [mailto:ganesh@magnusquest.com]
Sent: Monday, December 08, 2003 6:26 PM
To: pgsql-sql@postgresql.org; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Field Size

 

Can anyone tell me, what harm would setting a field size to 1000 characters do to the size?

 

By increasing the size, will the database require more space? Or does it only consume space if there is data in the field only?

 

Regards,

Ganesan

 

Re: Field Size

From
Bruno Wolff III
Date:
On Mon, Dec 08, 2003 at 18:36:57 +0530,
  Somasekhar Bangalore <sbangalore@zensutra.com> wrote:
> There is no harm in having a field size of 1000 character provided u use the proper datatype. Don't user char(1000).
Tryusing varchar(1000). 

And if the 1000 limit is just a large number you picked rather than a
real rule for your data, then you probably want to use the TEXT type.