By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,776 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,776 IT Pros & Developers. It's quick & easy.

varchar vs. text

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.