Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Richard Heyes
So where's the advantage of VARCHAR ?

 Less space on disc = less data retrieved from disc = faster data
 retrieval - sometimes. If you have small columns, a small number of
 rows, or both, then char columns may be faster. If you have large
 columns of varying actual length, lots of rows, or both, then varchar
 columns may be faster.

I still think a CHAR field would be faster than a VARCHAR because of
the fixed row length (assuming every thing else is fixed). Perhaps
someone from the MySQL list could clarify...?

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated January 4th)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Johan De Meersman
On Wed, Jan 7, 2009 at 2:26 PM, Richard Heyes rich...@php.net wrote:

 I still think a CHAR field would be faster than a VARCHAR because of
 the fixed row length (assuming every thing else is fixed). Perhaps
 someone from the MySQL list could clarify...?


Say that your column length goes up to 2000 bytes, but on average is less
than 512 bytes (ie. one disk block). What would be faster, reading 1 disk
block (varchar), or reading 4 disk blocks (char) ?






 --
 Richard Heyes

 HTML5 Graphing for FF, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 4th)

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=vegiv...@tuxera.be




-- 
Celsius is based on water temperature.
Fahrenheit is based on alcohol temperature.
Ergo, Fahrenheit is better than Celsius. QED.


Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Jim Lyons
There are other factors.  If a table is completely fixed in size it makes
for a faster lookup time since the offset is easier to compute.  This is
true, at least, for myisam tables.  All books on tuning that I have read
have said the CHAR makes for more efficient lookup and comparison that
VARCHAR.

Also, I was told by the instructor at a MySQL class that all VARCHAR columns
are converted to CHAR when stored in memory.  Can anyone else confirm this?

On Wed, Jan 7, 2009 at 7:26 AM, Richard Heyes rich...@php.net wrote:

 So where's the advantage of VARCHAR ?
 
  Less space on disc = less data retrieved from disc = faster data
  retrieval - sometimes. If you have small columns, a small number of
  rows, or both, then char columns may be faster. If you have large
  columns of varying actual length, lots of rows, or both, then varchar
  columns may be faster.

 I still think a CHAR field would be faster than a VARCHAR because of
 the fixed row length (assuming every thing else is fixed). Perhaps
 someone from the MySQL list could clarify...?

 --
 Richard Heyes

 HTML5 Graphing for FF, Chrome, Opera and Safari:
 http://www.rgraph.org (Updated January 4th)

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=jlyons4...@gmail.com




-- 
Jim Lyons
Web developer / Database administrator
http://www.weblyons.com


Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread David Giragosian
On 1/7/09, Jim Lyons jlyons4...@gmail.com wrote:

 There are other factors.  If a table is completely fixed in size it makes
 for a faster lookup time since the offset is easier to compute.  This is
 true, at least, for myisam tables.  All books on tuning that I have read
 have said the CHAR makes for more efficient lookup and comparison that
 VARCHAR.

 Also, I was told by the instructor at a MySQL class that all VARCHAR
 columns
 are converted to CHAR when stored in memory.  Can anyone else confirm this?


That's my recollection, also, derived from a MySQL class. IIRC, the char
length is equal to the longest varchar record in the column.

David


Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot

2009-01-07 Thread Baron Schwartz
On Wed, Jan 7, 2009 at 9:17 AM, David Giragosian dgiragos...@gmail.com wrote:
 On 1/7/09, Jim Lyons jlyons4...@gmail.com wrote:

 There are other factors.  If a table is completely fixed in size it makes
 for a faster lookup time since the offset is easier to compute.  This is
 true, at least, for myisam tables.  All books on tuning that I have read
 have said the CHAR makes for more efficient lookup and comparison that
 VARCHAR.

 Also, I was told by the instructor at a MySQL class that all VARCHAR
 columns
 are converted to CHAR when stored in memory.  Can anyone else confirm this?


 That's my recollection, also, derived from a MySQL class. IIRC, the char
 length is equal to the longest varchar record in the column.

Actually it's a fixed-length buffer big enough to hold the worst-case
possible value, not the worst-case existing value.  In bytes, no less.
 If it's a utf8 varchar(100), that's 300 bytes, even if the biggest
value in the table is one character.

-- 
Baron Schwartz, Director of Consulting, Percona Inc.
Our Blog: http://www.mysqlperformanceblog.com/
Our Services: http://www.percona.com/services.html

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org