<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Justin Carmony &#187; Bugs</title>
	<atom:link href="http://www.justincarmony.com/blog/tag/bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.justincarmony.com/blog</link>
	<description>Web Designer &#38; Software Engineer</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:30:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL Stored Procedure, NAME_CONST, and Character Sets</title>
		<link>http://www.justincarmony.com/blog/2011/02/02/mysql-stored-procedure-name_const-and-character-sets/</link>
		<comments>http://www.justincarmony.com/blog/2011/02/02/mysql-stored-procedure-name_const-and-character-sets/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 07:12:35 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[performance tuning]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=746</guid>
		<description><![CDATA[For a Project I had helped work on, they recently needed to move servers and in the process upgraded from MySQL 5.0 to MySQL 5.1.41. They ran into some quirks with 5.1 and I thought I would document our work-a-rounds for them. We were having serious performance problems with a Stored Procedure that would be ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/07/01/mysql-php-sql_calc_found_rows-an-easy-way-to-get-the-total-number-of-rows-regardless-of-limit/' rel='bookmark' title='MySQL &amp; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT'>MySQL &#038; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/03/mysql-does-table-exist-wo-throwing-errors/' rel='bookmark' title='MySQL &#8211; Does Table Exist w/o Throwing Errors'>MySQL &#8211; Does Table Exist w/o Throwing Errors</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/' rel='bookmark' title='MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes'>MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/02/mysql_logo.gif"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/02/mysql_logo.gif" alt="" title="mysql_logo" width="300" height="167" class="alignright size-full wp-image-748" /></a>For a Project I had helped work on, they recently needed to move servers and in the process upgraded from MySQL 5.0 to MySQL 5.1.41. They ran into some quirks with 5.1 and I thought I would document our work-a-rounds for them. </p>
<p>We were having serious performance problems with a Stored Procedure that would be called by a Windows Client on thousands of machines. Before on 5.0 it would take under 0.02 seconds, and now it was taking 25-35 seconds. In this stored procedure we would call a query something like this:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT u.id INTO spUserId FROM users u WHERE u.username = spUsername;
</pre>
<p>Where spUsername was a Stored Procedure variable of CHAR(50). So while the stored procedure was running I would execute a SHOW FULL PROCESSLIST; to see what the matter was. I would see the query, but MySQL 5.1 had substituted spUsername with a MySQL function, so it looked like this if the value of spUsername was &#8220;sheldon&#8221;:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT u.id INTO spUserId FROM users u WHERE u.username = NAME_CONST('userName',_utf8'sheldon' COLLATE 'utf8_unicode_ci');
</pre>
<p>So when I did an explain (and removed the INTO spUserId since it wasn&#8217;t needed to understand the lookup and would throw and error), I saw it was performing a full table scan. The table had near one million rows, so that was a very bad thing. It was completely ignoring the Index on u.username. At first I thought it was because of the NAME_CONST function, that it was doing something weird. To be honest, I was confused as to exactly why it was substituting it in the first place, since the documentation for NAME_CONST didn&#8217;t have anything to do with Stored Procedures.</p>
<p>Then I removed &#8220;_utf8&#8243; and &#8220;COLLATE &#8216;utf8_unicode_ci&#8217;&#8221; from the picture. Now I was getting somewhere, since it returned 1 row using the correct index. Now, the table users stored its data in the character set latin1_swedish_ci. So, ultimately, from what I can tell, it appears MySQL was reading the entire table, converting the table&#8217;s username field to utf8, instead of converting spUserName to latin1. The reason it thought to use utf8 was because the Windows Client when connecting set it&#8217;s session to use utf8 (I think, since I couldn&#8217;t quickly look at the source and verify this, but it was the assumption I made).</p>
<p><strong>Solution</strong></p>
<p>So I decided to manually cast the variable from UTF8 to Latin1 by using another Stored Procedure variable, executing this command:</p>
<pre class="brush: sql; title: ; notranslate">
SET @tmpUserName = CAST(userName AS CHAR CHARACTER SET latin1);
</pre>
<p>Then I modified my query to use the new variable:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT u.id INTO spUserId FROM users u WHERE u.username = @tmpUserName;
</pre>
<p>Bingo, I was back down to 0.0022 seconds for the Stored Procedure to execute, and the new Database server is screaming fast.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/07/01/mysql-php-sql_calc_found_rows-an-easy-way-to-get-the-total-number-of-rows-regardless-of-limit/' rel='bookmark' title='MySQL &amp; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT'>MySQL &#038; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/03/mysql-does-table-exist-wo-throwing-errors/' rel='bookmark' title='MySQL &#8211; Does Table Exist w/o Throwing Errors'>MySQL &#8211; Does Table Exist w/o Throwing Errors</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/' rel='bookmark' title='MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes'>MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/02/02/mysql-stored-procedure-name_const-and-character-sets/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>EA &#8211; Lack of Quality &amp; Out of Touch</title>
		<link>http://www.justincarmony.com/blog/2008/10/15/ea-lack-of-quality-out-of-touch/</link>
		<comments>http://www.justincarmony.com/blog/2008/10/15/ea-lack-of-quality-out-of-touch/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 19:04:30 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Video Gaming]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Electronic Arts]]></category>
		<category><![CDATA[Frustration]]></category>
		<category><![CDATA[Tiger Woods 09]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=233</guid>
		<description><![CDATA[An article posted on Slashdot just set me off today. Custom PC reports a quote from EA&#8216;s CEO, John Riccitiello, about DRM &#38; their recent games: ‘We implemented a form of DRM and it&#8217;s something that 99.8 per cent of users wouldn&#8217;t notice,’ claimed Riccitiello, ‘but for the other 0.2 percent, it became an issue ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/05/20/iphone-sdk-learning-the-basics-by-removing-the-touch/' rel='bookmark' title='iPhone SDK &#8211; Learning the Basics by Removing the Touch'>iPhone SDK &#8211; Learning the Basics by Removing the Touch</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/08/28/comcast-limit-to-250gb-a-month-for-residential/' rel='bookmark' title='Comcast Limit to 250GB a month for Residential'>Comcast Limit to 250GB a month for Residential</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/01/17/iphone-vista-64-bit-finally/' rel='bookmark' title='iPhone &amp; Vista 64-Bit&#8230;. Finally!'>iPhone &#038; Vista 64-Bit&#8230;. Finally!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>An article posted on <a href="http://games.slashdot.org/article.pl?sid=08/10/15/1525259&amp;from=rss" target="_blank">Slashdot </a>just set me off today. <a href="http://www.custompc.co.uk/news/605037/998-of-gamers-dont-care-about-drm-says-ea.html" target="_blank">Custom PC</a> reports a quote from <a href="http://en.wikipedia.org/wiki/Electronic_Arts" target="_blank">EA</a>&#8216;s CEO, John Riccitiello, about DRM &amp; their recent games:</p>
<blockquote><p>‘We implemented a form of DRM and it&#8217;s something that 99.8 per cent of users wouldn&#8217;t notice,’ claimed Riccitiello, ‘but for the other 0.2 percent, it became an issue and a number of them launched a cabal online to protest against it.’ The use of SecuROM in EA’s recent PC games, including Spore, Mass Effect and Crysis Warhead, has caused a lot of controversy on the Internet, resulting in hundreds of <a href="http://www.amazon.co.uk/review/product/B000FN7K2S/ref=cm_cr_pr_hist_1?%5Fencoding=UTF8&amp;filterBy=addOneStar" target="_blank">one-star reviews</a> on Amazon.</p></blockquote>
<p>99.8%? That is magical statistics at its best. I bought Spore, and I had an insanse time trying to get it to read the disc and install on my machine. SecuROM is extremely evasive, and when I re-format my machine, I have to go through the entire hassel again. To think that normal &#8220;gamers&#8221; don&#8217;t know mind these DRM tatics is total ignorance. I can&#8217;t backup my Spore DVD incase I lose it or it gets damanged. I&#8217;ve already written about <a href="http://www.justincarmony.com/blog/2008/07/26/drm-vs-users-the-good-and-the-bad/">my thoughts on DRM</a>, but I can&#8217;t help re-emphasis my point:</p>
<p>DRM doesn&#8217;t stop illegal downloads. It harms legal users try to use their purchase legally. DRM will never, ever, be succcessfully until it makes the <em><strong>users</strong></em> life easier.</p>
<p>The one example of DRM I love is <a href="http://store.steampowered.com/" target="_blank">Steam</a>. I buy a game once and it handles everything else for me. If I move computers, it works. If my computer blows up, it works. I can delete and re-download my game as many times as I want. It handles all updates for me. I can buy a game and play it within minutes, not needing to drive to the store. <em>Even if I go to a friends and show him a game on HIS PC it works.</em> Only one person can use it at a time, which for legal Steam owners is great. <em>Steam has make my life<strong> easier</strong> so I accept it. </em>I bought the game Crysis Warhead, and while the game&#8217;s quality was okay, I bought it on Steam and I had no problems with it.</p>
<p>Now, my other problem with EA is their quality of games. EA has turned into a video game assembly line. They pump out more games than any other company. But I will say their quality has also gone down the shaft. My personal latest example is with their game <a href="http://en.wikipedia.org/wiki/Tiger_Woods_PGA_Tour_09" target="_blank">Tiger Woods 09</a>. I managed to completely render my game on XBox 360 completely unplayable, all due to a clitch with the game, and took me several days to solve.</p>
<p>Somehow I managed to equip two gloves, right hand and left hand, on my character. I&#8217;m not sure how I did it, and I was playing when I realized &#8220;hey&#8230;. I have two gloves on?&#8221; I didn&#8217;t think much of it at the moment, saved and turned off my game, and waited several days before playing again. I went to turn on my game and it froze. I tried it several times, same behavior. After several hours of trial and error, I discovered the solution:</p>
<p>I had to first delete my game settings on my profile on the XBoX 360 hard drive. Then, I had to load the game and go the golfer manager. I then loaded my character, went to the &#8220;Pro Shop&#8221;, had to do an &#8220;item&#8221; search with several different combonations (which figuring it out crashed my xbox 7 or 8 times alone), and unquip the item. Finally I could save, restart my XBox, and play the game like normal.</p>
<p>Searching the internet for hours didn&#8217;t yeild any results. I tried to figure out how to contact EA for support, but gave up in the end after trying to create support acounts and jump through their hoops. Had it not been for me noticing my playered glitched, and understanding programming logic, I most likely would have never got my game to work again. What happened to Quality Assurance over at EA? I&#8217;m sure some poor gamer out there can&#8217;t play his game because he on accidently equiped a right-handed glove instead of a left.</p>
<p>I dunno, but I&#8217;m started to think I might just boycott EA all together.  Here are imagines of my dual wielding glove golfer, for proof that I really did go through all this mess:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2008/10/img_0021.jpg"><img class="size-medium wp-image-235 alignnone" title="img_0021" src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2008/10/img_0021-300x225.jpg" alt="" width="300" height="225" /></a><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2008/10/img_0020.jpg"><img class="size-medium wp-image-234 alignnone" title="img_0020" src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2008/10/img_0020-225x300.jpg" alt="" width="225" height="300" /></a><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2008/10/img_0023.jpg"><img class="alignnone size-medium wp-image-237" title="img_0023" src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2008/10/img_0023-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><em>Note: I took these on my iPhone quickly, so I know the quality isn&#8217;t that great.</em></p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/05/20/iphone-sdk-learning-the-basics-by-removing-the-touch/' rel='bookmark' title='iPhone SDK &#8211; Learning the Basics by Removing the Touch'>iPhone SDK &#8211; Learning the Basics by Removing the Touch</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/08/28/comcast-limit-to-250gb-a-month-for-residential/' rel='bookmark' title='Comcast Limit to 250GB a month for Residential'>Comcast Limit to 250GB a month for Residential</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/01/17/iphone-vista-64-bit-finally/' rel='bookmark' title='iPhone &amp; Vista 64-Bit&#8230;. Finally!'>iPhone &#038; Vista 64-Bit&#8230;. Finally!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2008/10/15/ea-lack-of-quality-out-of-touch/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 18/45 queries in 0.018 seconds using memcached
Content Delivery Network via Rackspace Cloud Files: c747925.r25.cf2.rackcdn.com

Served from: www.justincarmony.com @ 2012-02-07 20:04:13 -->
