>>>>> "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.
Hi!
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.
Regards,
Monty