List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:April 10 1999 9:02am
Subject:Re: varchar vs text
View as plain text  
>>>>> "Sasha" == Sasha Pachev <sasha@stripped> writes:

Sasha> Michael Widenius wrote:
>> >>>>> "Sasha" == Sasha Pachev <sasha@stripped> writes:
Sasha> Is there any difference in performance between varchar
Sasha> and text?
>> Hi!
>> Yes;  VARCHAR is slower.
>> This is documented in the MySQL manual; Search after 'fixed size
>> rows'!
>> Regards,
>> Monty

Sasha> Monty,

Sasha> The manual talks about varchar vs char, which obviously favors char
Sasha> because of fixed length. However, both text and varchar have variable
Sasha> length, so there seem to be no apparent reason for one to be much faster
Sasha> than the other.


Sorry, my mistake: I accidently read 'varchar' and 'char'.

The main difference between VARCHAR and TEXT is how they are stored
in memory:

- All VARCHAR columns are stored as pre-alloced CHAR arrays
  in memory and MySQL treats them as ordinary CHAR columns;  It's the
  ISAM that automaticly removes all end space from the VARCHAR column
  to save it more efficiently on disk.

- A TEXT/BLOB column is dynamicly alloced

The above means that VARCHAR takes a little more memory but there are
much fewer memory reallocations than with TEXT/BLOB.  As memory
reallocation is usually quite slow, VARCHAR should be a little faster than
TEXT/BLOB in most cases;  In most case the speed difference is
probably neglectable.


varchar vs textSasha Pachev5 Apr
  • varchar vs textMichael Widenius6 Apr
    • Re: varchar vs textPaul DuBois6 Apr
  • Re: varchar vs textSasha Pachev6 Apr
    • Full text search?Fraser MacKenzie6 Apr
      • Re: Full text search?Thimble Smith6 Apr
        • Re: Full text search?Michael Widenius10 Apr
    • Re: varchar vs textMichael Widenius10 Apr