469,352 Members | 2,140 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

varchar vs. text

I curious about the benefits of a varchar over text. Is it speed,
size? If so, how much speed, size? Is a varchar(64) and a text with 64
chars the same size? I'm inclined to make all my varchars into text so
I don't have to worry about inserting something to big.

TIA,
Michael
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #1
4 8319
Michael Garriss <mg******@earthlink.net> writes:
I curious about the benefits of a varchar over text.
1. Compliance to the letter of the SQL spec.
2. Ability to define a maximum length, if you happen to feel the need to
impose a specific maximum length. (If you don't have a good reason
to impose any particular max length, this is a minus not a plus,
because the spec says you have to pick one anyway.)
Is it speed,


It's a loser on speed because of the extra cycles spent to check the
max length. Other than those cycles, there is no difference.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #2
Tom Lane wrote:
Michael Garriss <mg******@earthlink.net> writes:

I curious about the benefits of a varchar over text.


1. Compliance to the letter of the SQL spec.
2. Ability to define a maximum length, if you happen to feel the need to
impose a specific maximum length. (If you don't have a good reason
to impose any particular max length, this is a minus not a plus,
because the spec says you have to pick one anyway.)
Is it speed,


It's a loser on speed because of the extra cycles spent to check the
max length. Other than those cycles, there is no difference.

regards, tom lane

Thanks for the quick response.

Michael

P.S. The code I'm writing is going to be ported to MySQL by a friend.
Do you have any idea if TEXT is supported over there?
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #3
On Wed, 2003-09-17 at 22:59, Michael Garriss wrote:
I curious about the benefits of a varchar over text. Is it speed,
size? If so, how much speed, size? Is a varchar(64) and a text with 64
chars the same size? I'm inclined to make all my varchars into text so
I don't have to worry about inserting something to big.


An analyst would say that "correctness" is a reason for specifying
a max length. For example, in t_names, I could stick "War and Peace"
into first_name, but, obviously, that's not "correct".

CREATE TABLE t_names (
first_name TEXT,
last_name TEXT );

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@cox.net
Jefferson, LA USA

"(Women are) like compilers. They take simple statements and
make them into big productions."
Pitr Dubovitch
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #4
In article <3F**************@earthlink.net>,
Michael Garriss <mg******@earthlink.net> writes:
P.S. The code I'm writing is going to be ported to MySQL by a friend.
Shame on you for having a friend using MySQL ;-)
Do you have any idea if TEXT is supported over there?


Yes: http://www.mysql.com/doc/en/BLOB.html
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Berislav Lopac | last post: by
6 posts views Thread by Bill | last post: by
5 posts views Thread by dmhendricks | last post: by
10 posts views Thread by Techie | last post: by
4 posts views Thread by Nick Chan | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.