Discussion:
Field Size
(too old to reply)
Ganesan Kanavathy
2003-12-08 12:56:06 UTC
Permalink
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
Marc A. Leith
2003-12-08 13:03:12 UTC
Permalink
If you define the field as CHAR, 1000 bytes will be consumed.

If you define the field as VARCHAR, on sufficient bytes to store the contents will be used.

Marc

--Original Message Text---
From: Ganesan Kanavathy
Date: Mon, 8 Dec 2003 20:56:06 +0800

Clean Clean DocumentEmail MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-
colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-
orphan; font-size:10.0pt; font-family:"Times New Roman";}

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






Marc A. Leith
President
redboxdata inc.

e-mail: ***@redboxdata.com
cell: (416) 737 0045
Somasekhar Bangalore
2003-12-08 13:06:57 UTC
Permalink
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:***@magnusquest.com]
Sent: Monday, December 08, 2003 6:26 PM
To: pgsql-***@postgresql.org; pgsql-***@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
Bruno Wolff III
2003-12-08 15:35:52 UTC
Permalink
On Mon, Dec 08, 2003 at 18:36:57 +0530,
Post by Somasekhar Bangalore
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).
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.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Loading...