<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Common wrong Data Types compilation</title>
	<atom:link href="http://code.openark.org/blog/mysql/common-data-types-errors-compilation/feed" rel="self" type="application/rss+xml" />
	<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation</link>
	<description>Blog by Shlomi Noach</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:47:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-2717</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Mon, 20 Jul 2009 06:52:27 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-2717</guid>
		<description>Hi Ann,

Thanks for sharing your experience.
In two customer cases I&#039;ve had, and in which we&#039;ve changed data types throughout the schema, we&#039;ve reached 50% savings in disk space, just due to proper data types + charsets.
I personally see this as basic and important part for auditing.

Obviously, there are other parameters to consider. But I think laying out the basics properly, gives boost to further steps.

Regards.
Shlomi</description>
		<content:encoded><![CDATA[<p>Hi Ann,</p>
<p>Thanks for sharing your experience.<br />
In two customer cases I've had, and in which we've changed data types throughout the schema, we've reached 50% savings in disk space, just due to proper data types + charsets.<br />
I personally see this as basic and important part for auditing.</p>
<p>Obviously, there are other parameters to consider. But I think laying out the basics properly, gives boost to further steps.</p>
<p>Regards.<br />
Shlomi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: annie</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-2685</link>
		<dc:creator>annie</dc:creator>
		<pubDate>Thu, 16 Jul 2009 19:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-2685</guid>
		<description>Hi,

In my experience having smallint vs int was more to save space but does not necessarily influence performance at least not something noticeable.  Many times I come across some white papers where people are trying  to prove a point, I run the test and the method they are trying to prove wrong has better performance than the one they are in favor.  I have done such test even with the white paper coming out of the company that created the software.  

Most of the time, the approach to design / architect databases or application depends on what you are trying to accomplish and what kind of usage the system will be for.   Doing consulting for many many years, I&#039;ve come across multiple approaches and styles and if sit down and analyze each one of them they all would have valid justification for their approach or design.  It is funny but the more experienced I&#039;ve gotten the less adamant and less critical I have become.  This does not mean that I am in favor of carelessness and the obvious.    

Thanks,

Ann</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>In my experience having smallint vs int was more to save space but does not necessarily influence performance at least not something noticeable.  Many times I come across some white papers where people are trying  to prove a point, I run the test and the method they are trying to prove wrong has better performance than the one they are in favor.  I have done such test even with the white paper coming out of the company that created the software.  </p>
<p>Most of the time, the approach to design / architect databases or application depends on what you are trying to accomplish and what kind of usage the system will be for.   Doing consulting for many many years, I've come across multiple approaches and styles and if sit down and analyze each one of them they all would have valid justification for their approach or design.  It is funny but the more experienced I've gotten the less adamant and less critical I have become.  This does not mean that I am in favor of carelessness and the obvious.    </p>
<p>Thanks,</p>
<p>Ann</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-2683</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Thu, 16 Jul 2009 17:15:15 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-2683</guid>
		<description>Hi Ann,

Not really :)
I stand corrected on hexadecimal values;
IPv4 is still *very much* widespread;
MEDIUMINT is undesired on InnoDB.

The arguments are still very much valid. Not as starting point, but as start-to-end argument.

(Though I am very much susceptible to error and will gladly stand corrected on any point I make)

Regards</description>
		<content:encoded><![CDATA[<p>Hi Ann,</p>
<p>Not really <img src='http://code.openark.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I stand corrected on hexadecimal values;<br />
IPv4 is still *very much* widespread;<br />
MEDIUMINT is undesired on InnoDB.</p>
<p>The arguments are still very much valid. Not as starting point, but as start-to-end argument.</p>
<p>(Though I am very much susceptible to error and will gladly stand corrected on any point I make)</p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: annie</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-2682</link>
		<dc:creator>annie</dc:creator>
		<pubDate>Thu, 16 Jul 2009 16:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-2682</guid>
		<description>It seems that all the original arguments from shlomi where 
refuted.  When it comes to IT if you have 5 people you most likely end up with 7 opinions!!!  However the recommendation are still valid for a starting point the rest is preference.

Ann</description>
		<content:encoded><![CDATA[<p>It seems that all the original arguments from shlomi where<br />
refuted.  When it comes to IT if you have 5 people you most likely end up with 7 opinions!!!  However the recommendation are still valid for a starting point the rest is preference.</p>
<p>Ann</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Designing relational databases for PHP in MySQL &#124; The Struggle</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-2667</link>
		<dc:creator>Designing relational databases for PHP in MySQL &#124; The Struggle</dc:creator>
		<pubDate>Wed, 15 Jul 2009 14:34:40 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-2667</guid>
		<description>[...] choosing the wrong data type [...]</description>
		<content:encoded><![CDATA[<p>[...] choosing the wrong data type [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garrett W.</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-2071</link>
		<dc:creator>Garrett W.</dc:creator>
		<pubDate>Mon, 25 May 2009 19:48:02 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-2071</guid>
		<description>The only thing about storing the MD5s as binary is that you have to remember to do the HEX()/UNHEX() to use them as text in your application - a minor difficulty for sure, but an invitation for unintentional programming bugs.

Maybe.</description>
		<content:encoded><![CDATA[<p>The only thing about storing the MD5s as binary is that you have to remember to do the HEX()/UNHEX() to use them as text in your application - a minor difficulty for sure, but an invitation for unintentional programming bugs.</p>
<p>Maybe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: מסד נתונים - הגדרת סוגי שדות נכונים בהתאם לשדה &#124; ואדים גבריאל</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-733</link>
		<dc:creator>מסד נתונים - הגדרת סוגי שדות נכונים בהתאם לשדה &#124; ואדים גבריאל</dc:creator>
		<pubDate>Thu, 19 Feb 2009 12:57:23 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-733</guid>
		<description>[...] קראתי פוסט של שלומי נוח לגבי הטעויות הנפוצות בהגדרת סוגי השדות למסד הנתונים. [...]</description>
		<content:encoded><![CDATA[<p>[...] קראתי פוסט של שלומי נוח לגבי הטעויות הנפוצות בהגדרת סוגי השדות למסד הנתונים. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-195</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Fri, 26 Dec 2008 17:28:59 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-195</guid>
		<description>Aaron - thanks!

Shlomi</description>
		<content:encoded><![CDATA[<p>Aaron - thanks!</p>
<p>Shlomi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Suggs</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-194</link>
		<dc:creator>Aaron Suggs</dc:creator>
		<pubDate>Fri, 26 Dec 2008 15:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-194</guid>
		<description>Roland and Shiomi,

I store MD5 sums as binary(16). The HEX() and UNHEX() functions allow you to convert between binary data and the application-friendly hexadecimal string.

HEX() converts binary data to a string.
UNHEX() converts a string to binary data.

I recommend storing other fixed-length hexadecimal strings as binary data. E.g., UUIDs are binary(16), and SHA1 hashes are binary(20).

Here&#039;s an example of a table with binary(16) column for MD5 hashes:

mysql&gt; create table t(md5 binary(16)) engine=innodb;

To store the MD5 &quot;f7699c9e31b648197a20805989ac0db8&quot;, use the UNHEX function:

mysql&gt; insert into t values (unhex(&quot;f7699c9e31b648197a20805989ac0db8&quot;));
Query OK, 1 row affected (0.00 sec)

And retrieve it as a string using the HEX function:

mysql&gt; select hex(md5) from t;
+----------------------------------+
&#124; hex(md5) &#124;
+----------------------------------+
&#124; F7699C9E31B648197A20805989AC0DB8 &#124;
+----------------------------------+
1 row in set (0.00 sec)

Tada!

Cheers,
Aaron</description>
		<content:encoded><![CDATA[<p>Roland and Shiomi,</p>
<p>I store MD5 sums as binary(16). The HEX() and UNHEX() functions allow you to convert between binary data and the application-friendly hexadecimal string.</p>
<p>HEX() converts binary data to a string.<br />
UNHEX() converts a string to binary data.</p>
<p>I recommend storing other fixed-length hexadecimal strings as binary data. E.g., UUIDs are binary(16), and SHA1 hashes are binary(20).</p>
<p>Here's an example of a table with binary(16) column for MD5 hashes:</p>
<p>mysql&gt; create table t(md5 binary(16)) engine=innodb;</p>
<p>To store the MD5 "f7699c9e31b648197a20805989ac0db8", use the UNHEX function:</p>
<p>mysql&gt; insert into t values (unhex("f7699c9e31b648197a20805989ac0db8"));<br />
Query OK, 1 row affected (0.00 sec)</p>
<p>And retrieve it as a string using the HEX function:</p>
<p>mysql&gt; select hex(md5) from t;<br />
+----------------------------------+<br />
| hex(md5) |<br />
+----------------------------------+<br />
| F7699C9E31B648197A20805989AC0DB8 |<br />
+----------------------------------+<br />
1 row in set (0.00 sec)</p>
<p>Tada!</p>
<p>Cheers,<br />
Aaron</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #124: a Carnival of the Vanities for DBAs</title>
		<link>http://code.openark.org/blog/mysql/common-data-types-errors-compilation/comment-page-1#comment-34</link>
		<dc:creator>Log Buffer #124: a Carnival of the Vanities for DBAs</dc:creator>
		<pubDate>Fri, 21 Nov 2008 17:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=85#comment-34</guid>
		<description>[...] code.openark.org&#8217;s Shlomi Noach also was in the business of setting developers&#8217; heads straight (and those of others besides) with his common wrong data types compilation. [...]</description>
		<content:encoded><![CDATA[<p>[...] code.openark.org&#8217;s Shlomi Noach also was in the business of setting developers&#8217; heads straight (and those of others besides) with his common wrong data types compilation. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

