MySQL Forums
Forum List  »  Newbie

Re: Query to find values that are the same in multiple tables
Posted by: Rick James
Date: November 30, 2010 12:18AM

VARCHAR vs CHAR -- space.
CHAR(100) occupies space for 100 characters.
VARCHAR(100) occupies 1 byte for a length, plus as many characters as needed.
For, say, a "name" field, you need to allow enough space for the longest name, say VARCHAR(40). But a name like Joe takes only 4 bytes; no need to waste the 36 more for CHAR(40).

When you get into utf8 characters, it gets worse. CHAR(100) will occupy 300 bytes because the longest utf8 character (as implemented in MySQL) takes 3 bytes. "Joe" would still take 4 bytes in a VARCHAR(100), nearly 99% smaller.

Options: ReplyQuote


Subject
Written By
Posted
Re: Query to find values that are the same in multiple tables
November 30, 2010 12:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.