Varchar vs. text

This is a discussion on Varchar vs. text within the PHP Language forums, part of the PHP Programming Forums category; I was lately wandering what would be the advantage of using varchar instead of text column data type in a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-26-2004
Berislav Lopac
 
Posts: n/a
Default Varchar vs. text

I was lately wandering what would be the advantage of using varchar instead
of text column data type in a database (specificall MySQL, but this might
also be the case for other databases)? I mean, both of them are variable
length, both can be indexed, and text can hold a lot more data...

I'm just looking for some other opinions on the subjects.

Berislav


Reply With Quote
  #2 (permalink)  
Old 01-26-2004
Jerome H. Gitomer
 
Posts: n/a
Default Re: Varchar vs. text

Berislav Lopac wrote:
> I was lately wandering what would be the advantage of using varchar instead
> of text column data type in a database (specificall MySQL, but this might
> also be the case for other databases)? I mean, both of them are variable
> length, both can be indexed, and text can hold a lot more data...
>
> I'm just looking for some other opinions on the subjects.
>
> Berislav
>
>

I prefer VARCHAR since some other RDBMS support VARCHAR but not
TEXT. If you will never migrate it doesn't matter, but if you
ever do it may.

HTH
Jerry

Reply With Quote
  #3 (permalink)  
Old 01-26-2004
Tim Van Wassenhove
 
Posts: n/a
Default Re: Varchar vs. text

On 2004-01-26, Berislav Lopac <berislav.lopac@dimedia.hr> wrote:
> I was lately wandering what would be the advantage of using varchar instead
> of text column data type in a database (specificall MySQL, but this might
> also be the case for other databases)? I mean, both of them are variable
> length, both can be indexed, and text can hold a lot more data...
>
> I'm just looking for some other opinions on the subjects.


The exact differences are mentionned in the MySQL manual.

--
http://home.mysth.be/~timvw
Reply With Quote
  #4 (permalink)  
Old 01-26-2004
Jochen Daum
 
Posts: n/a
Default Re: Varchar vs. text

hi!

On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac"
<berislav.lopac@dimedia.hr> wrote:

>I was lately wandering what would be the advantage of using

varchar instead
>of text column data type in a database (specificall MySQL, but this might
>also be the case for other databases)? I mean, both of them are variable
>length, both can be indexed, and text can hold a lot more data...
>
>I'm just looking for some other opinions on the subjects.


Some DBMS store a text in a separate page (eg. MSSQL 7 and 2000 [by
default]), so you would have an unnecessary page hit for certain size
varchars.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Reply With Quote
  #5 (permalink)  
Old 01-26-2004
Capt. Beefheart
 
Posts: n/a
Default Re: Varchar vs. text

Berislav

I would imagine that varchar and text are from the days when disk space
was at a premium, that is, there wasn't much of it. Consquently varchar
would be used unless large amounts of text were going to be inserted
into a field. Of course with the problem of disk space no longer an
issue varchar could be considered defunct. Well at least in MySQL. Other
RDBMS's only use BLOB fields which can't be indexed.

Beefy

Berislav Lopac wrote:
> I was lately wandering what would be the advantage of using varchar instead
> of text column data type in a database (specificall MySQL, but this might
> also be the case for other databases)? I mean, both of them are variable
> length, both can be indexed, and text can hold a lot more data...
>
> I'm just looking for some other opinions on the subjects.
>
> Berislav
>
>


Reply With Quote
  #6 (permalink)  
Old 01-26-2004
Jochen Daum
 
Posts: n/a
Default Re: Varchar vs. text

Hi Berislav!

On Mon, 26 Jan 2004 21:22:56 +0000, "Capt. Beefheart"
<Captain.Beefheart@crystalfalls.com> wrote:

>Berislav
>
>I would imagine that varchar and text are from the days when disk space
>was at a premium, that is, there wasn't much of it. Consquently varchar
>would be used unless large amounts of text were going to be inserted
>into a field. Of course with the problem of disk space no longer an
>issue varchar could be considered defunct. Well at least in MySQL. Other
>RDBMS's only use BLOB fields which can't be indexed.


Not diskspace directky, but disk page accesses are *THE* premium, when
working with databases. Nearly all optimisations come down to
minimizing disk access. As soon as your database grows out of your
main memory, it is an issue.

HTH, Jochen
>
>Beefy
>
>Berislav Lopac wrote:
>> I was lately wandering what would be the advantage of using varchar instead
>> of text column data type in a database (specificall MySQL, but this might
>> also be the case for other databases)? I mean, both of them are variable
>> length, both can be indexed, and text can hold a lot more data...
>>
>> I'm just looking for some other opinions on the subjects.
>>
>> Berislav
>>
>>


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Reply With Quote
  #7 (permalink)  
Old 01-27-2004
Chung Leong
 
Posts: n/a
Default Re: Varchar vs. text

Yup. Text/ntext fields are agonizingly slow in MSSQL 2000. Rows are limited
to 8000 bytes, so sometimes you're forced to use them. Accessing varchar
wider than 255 is a major pain too using PHP.

Uzytkownik "Jochen Daum" <jochen.daum@cans.co.nz> napisal w wiadomosci
news:vjta10h9rha6aj16aolcuijlvph5i6r8dr@4ax.com...
> hi!
>
> On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac"
> <berislav.lopac@dimedia.hr> wrote:
>
> >I was lately wandering what would be the advantage of using

> varchar instead
> >of text column data type in a database (specificall MySQL, but this might
> >also be the case for other databases)? I mean, both of them are variable
> >length, both can be indexed, and text can hold a lot more data...
> >
> >I'm just looking for some other opinions on the subjects.

>
> Some DBMS store a text in a separate page (eg. MSSQL 7 and 2000 [by
> default]), so you would have an unnecessary page hit for certain size
> varchars.
>
> HTH, Jochen
> --
> Jochen Daum - CANS Ltd.
> PHP DB Edit Toolkit -- PHP scripts for building
> database editing interfaces.
> http://sourceforge.net/projects/phpdbedittk/



Reply With Quote
  #8 (permalink)  
Old 01-27-2004
Jochen Daum
 
Posts: n/a
Default Re: Varchar vs. text


Hi Chung!

On Mon, 26 Jan 2004 21:29:12 -0500, "Chung Leong"
<chernyshevsky@hotmail.com> wrote:

>Yup. Text/ntext fields are agonizingly slow in MSSQL 2000. Rows are limited
>to 8000 bytes, so sometimes you're forced to use them. Accessing varchar
>wider than 255 is a major pain too using PHP.


I actually thought this is a FreeTDS issue. If you set the Version to
7.0, eg. export TDSVER=7.0, (or similar for SQL 2000) you have no
problem retrieving 8000 chars.

For most applications I'm quite happy to use varchar. If it gets
bigger you have to consider the backup process as well anyway and then
it gets tricky.

HTH, Jochen

>
>Uzytkownik "Jochen Daum" <jochen.daum@cans.co.nz> napisal w wiadomosci
>news:vjta10h9rha6aj16aolcuijlvph5i6r8dr@4ax.com.. .
>> hi!
>>
>> On Mon, 26 Jan 2004 15:41:06 +0100, "Berislav Lopac"
>> <berislav.lopac@dimedia.hr> wrote:
>>
>> >I was lately wandering what would be the advantage of using

>> varchar instead
>> >of text column data type in a database (specificall MySQL, but this might
>> >also be the case for other databases)? I mean, both of them are variable
>> >length, both can be indexed, and text can hold a lot more data...
>> >
>> >I'm just looking for some other opinions on the subjects.

>>
>> Some DBMS store a text in a separate page (eg. MSSQL 7 and 2000 [by
>> default]), so you would have an unnecessary page hit for certain size
>> varchars.
>>
>> HTH, Jochen
>> --
>> Jochen Daum - CANS Ltd.
>> PHP DB Edit Toolkit -- PHP scripts for building
>> database editing interfaces.
>> http://sourceforge.net/projects/phpdbedittk/

>


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0