MySQL Forums
Forum List  »  Performance

Re: text vs varchar
Posted by: Øystein Grøvlen
Date: May 03, 2016 02:19AM

From the reference manual (

"If a row is less than half a page long, all of it is stored locally within the page. If it exceeds half a page, variable-length columns are chosen for external off-page storage until the row fits within half a page."

Default page size is 16k. Hence, if a column value is more than 8k, it will definitely be stored off-page. Also, smaller values may be stored off-page if total row size is larger than 8k. Note that the number of bytes used per character depends on the character set used. If stored off-page, it will not be read when during table scans unless the column is actually needed.

Whether it is useful to store columns in a separate table will depend on your access pattern. If you do a lot of table scans or range scans on PRIMARY key, you would want the table to be as small as possible. If you do mostly key look-ups, table size does not matter than much. If you store the columns in a separate table, you will have extra overhead when fetching these columns since a join will be needed.

Hope this helps,

Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway

Options: ReplyQuote

Written By
April 28, 2016 08:36AM
April 29, 2016 12:41AM
April 30, 2016 11:51PM
May 02, 2016 04:37AM
May 02, 2016 09:14PM
Re: text vs varchar
May 03, 2016 02:19AM
May 03, 2016 04:12AM
May 02, 2016 08:02PM
May 03, 2016 02:25AM

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.