Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For what it's worth, the integer argument (e.g. <code>INT(11)</code>) is not meaningful for storage or optimization in any way. The argument does not indicate a max length or max range of values, it's only a hint for display. This confuses a lot of MySQL users, perhaps because they're used to <code>CHAR(11)</code> indicating max length. Not so with integers. <code>TINYINT(1)</code> and <code>TINYINT(11)</code> and <code>TINYINT(255)</code> are stored identically as an 8-bit integer, and they have the same range of values.</p> <p>The max length of an email address is 320 characters. 64 for the local part, 1 for <code>@</code>, and 255 for the domain.</p> <p>I am not a fan of using <code>VARCHAR(255)</code> as a default string declaration. Why is 255 the right length? Is 254 just not long enough and 256 seems too much? The answer is that people believe that the length of each string is stored somewhere, and by limiting the length to 255 they can ensure that the length only takes 1 byte. They've "optimized" by allowing as long a string as they can while still keeping the length to 1 byte.</p> <p>In fact, the length of the field is <em>not</em> stored in InnoDB. The <em>offset</em> of each field in the row is stored (see <a href="http://forge.mysql.com/wiki/MySQL_Internals_InnoDB" rel="nofollow noreferrer">MySQL Internals InnoDB</a>). If your total row length is 255 or less, the offsets use 1 byte. If your total row length could be longer than 255, the offsets use 2 bytes. Since you have several long fields in your row, it's almost certain to store the offsets in two bytes anyway. The ubiquitous value 255 may be optimized for some other RDBMS implementation, but not InnoDB.</p> <p>Also, MySQL converts rows to a fixed-length format in some cases, padding variable-length fields as necessary. For example, when copying rows to a sort buffer, or storing in a MEMORY table, or preparing the buffer for a result set, it has to allocate memory based on the maximum length of the columns, not the length of usable data on a per-row basis. So if you declare VARCHAR columns far longer than you ever actually use, you're wasting memory in those cases.</p> <p>This points out the hazard of trying to optimize too finely for a particular storage format.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload