<?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>Josh Highland &#187; MySQL</title>
	<atom:link href="http://joshhighland.com/blog/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshhighland.com/blog</link>
	<description>the living internet</description>
	<lastBuildDate>Sat, 20 Mar 2010 00:09:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server 2008: FIXED &#8220;Data has changed since the Results pane was last retrieved&#8221;</title>
		<link>http://joshhighland.com/blog/2010/02/03/sql-server-2008-fixed-data-has-changed-since-the-results-pane-was-last-retrieved/</link>
		<comments>http://joshhighland.com/blog/2010/02/03/sql-server-2008-fixed-data-has-changed-since-the-results-pane-was-last-retrieved/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:30:27 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[ms sql]]></category>
		<category><![CDATA[ssms]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=1045</guid>
		<description><![CDATA[
Today I was trying to edit the value in a table cell through the query browser in Microsoft SQL Server Management Itudio and I kept getting the following error:
Data has changed since the Results pane was last retrieved. Do you want to save your changes now?
(Optimistic Concurrency Control Error)
Click Yes to commit your changes to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1049 aligncenter" title="Screen shot 2010-02-03 at 12.16.11 AM" src="http://joshhighland.com/blog/wp-content/uploads/2010/02/Screen-shot-2010-02-03-at-12.16.11-AM.png" alt="" width="381" height="87" /></p>
<p>Today I was trying to edit the value in a table cell through the query browser in Microsoft SQL Server Management Itudio and I kept getting the following error:</p>
<blockquote><p>Data has changed since the Results pane was last retrieved. Do you want to save your changes now?<br />
(Optimistic Concurrency Control Error)<br />
Click Yes to commit your changes to database anyway.<br />
Click No to discard your change and retrieve the current data for this row.<br />
Click Cancel to continue editing.</p></blockquote>
<p><a href="http://joshhighland.com/blog/wp-content/uploads/2010/02/occe.jpg"><img class="aligncenter size-full wp-image-1046" title="occe" src="http://joshhighland.com/blog/wp-content/uploads/2010/02/occe.jpg" alt="" width="604" height="268" /></a></p>
<p>I would click &#8220;Yes&#8221;, and get another error:</p>
<blockquote><p>No row was updated.<br />
The data in row X was not committed.<br />
Error Source: Microsoft.VisualStudio.DataTools.<br />
Error Message: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(N rows).<br />
Correct the errors and retry or press ESC to cancel the change(s).</p></blockquote>
<p>I was killing myself trying to figure out what was wrong. I was the only person working on the database, so the data wasnt being changed behind my back.</p>
<p>After an hour on goolge I came across a Microsoft tech article for MS SQL 2005, <a href="http://support.microsoft.com/kb/925719">http://support.microsoft.com/kb/925719</a></p>
<p>It stated the issue could occure from one of the following conditions:</p>
<ul>
<li>The table contains one or more columns of the text or ntext data type.</li>
<li>The value of one of these columns contains the following characters:</li>
<li>Percent sign (%)</li>
<li>Underscore (_)</li>
<li>Left bracket ([)</li>
<li><strong>The table does not contain a primary key.</strong></li>
</ul>
<p>I double checked the table I was working on and realized it didnt have a primary key. It must have gotten dropped in the data migration from MS SQL 2000 to MS SQL 2008. A simple right click, set primary key and my problem was fixed.</p>
<p><a href="http://joshhighland.com/blog/wp-content/uploads/2010/02/setPrimaryKey.jpg"><img class="aligncenter size-full wp-image-1047" title="setPrimaryKey" src="http://joshhighland.com/blog/wp-content/uploads/2010/02/setPrimaryKey.jpg" alt="" width="328" height="300" /></a></p>
<p>Verify the primary keys! It&#8217;s a simple fix to a head breaker of a problem. I hope someone finds this and it fixes their issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2010/02/03/sql-server-2008-fixed-data-has-changed-since-the-results-pane-was-last-retrieved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpBB admin password manual reset</title>
		<link>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/</link>
		<comments>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 07:51:36 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[semi-legal]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=607</guid>
		<description><![CDATA[
Today I ran into a situation where I had forgotten the password to my development instance of phpBB 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn&#8217;t be the problem. The real problem is that phpBB uses [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-606" title="phpbb_logo" src="http://joshhighland.com/blog/wp-content/uploads/2009/03/phpbb_logo.jpg" alt="phpbb_logo" width="206" height="158" /></p>
<p>Today I ran into a situation where I had forgotten the password to my development instance of <a href="http://www.phpbb.com">phpBB</a> 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn&#8217;t be the problem. The real problem is that phpBB uses its own password hashing, not MD5.</p>
<p>In a work around, I created a new user and used the password &#8220;123456&#8243; looking at the database , in the users table of the phpBB install. I saw the &#8220;user_password&#8221; field was &#8220;e10adc3949ba59abbe56e057f20f883e&#8221;.</p>
<p>I then changed my admin accounts user to the same string, &#8220;e10adc3949ba59abbe56e057f20f883e&#8221;.</p>
<p><a href="http://joshhighland.com/blog/wp-content/uploads/2009/03/phpbbpasswordreset.gif"><img class="alignnone size-full wp-image-608" title="phpbbpasswordreset" src="http://joshhighland.com/blog/wp-content/uploads/2009/03/phpbbpasswordreset.gif" alt="phpbbpasswordreset" width="536" height="66" /></a></p>
<p>I went to the phpBB login screen, fillled out my username, and entered the password &#8220;123456&#8243;&#8230; BINGO! it worked.</p>
<p>So to save you the work. You can follow what I did or just use these hashes to reset your own password:</p>
<p><strong>Hash:</strong> e10adc3949ba59abbe56e057f20f883e<br />
<strong>Password:</strong> 123456</p>
<p><strong>Hash:</strong> $H$9Ae3Uk.ECdWW5ya13M4ErWhr4c.761/<br />
<strong>Password:</strong> password</p>
<p>I hope this helps someone else out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually reset your WordPress password</title>
		<link>http://joshhighland.com/blog/2009/02/13/manually-reset-your-wordpress-password/</link>
		<comments>http://joshhighland.com/blog/2009/02/13/manually-reset-your-wordpress-password/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 23:23:08 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=526</guid>
		<description><![CDATA[
It doesn&#8217;t matter what application your working with, losing your password is always a pain in the ass. Luckly if you are working with wordpress (man, I blog a lot about wordpress these days), on your server and you have access to the MySql database, resetting your password manually is a snap.

Login to your PhpMyAdmin
Select [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-528" title="lost-wordpress-password" src="http://joshhighland.com/blog/wp-content/uploads/2009/02/lost-wordpress-password.png" alt="lost-wordpress-password" width="297" height="383" /></p>
<p>It doesn&#8217;t matter what application your working with, losing your password is always a pain in the ass. Luckly if you are working with wordpress (man, I blog a lot about wordpress these days), on your server and you have access to the MySql database, resetting your password manually is a snap.</p>
<ul>
<li>Login to your PhpMyAdmin</li>
<li>Select your WordPress database and click on the &#8220;SQL&#8221; button to open the SQL query window.</li>
</ul>
<p><img class="alignnone size-full wp-image-527" title="wordpress-phpmyadmin" src="http://joshhighland.com/blog/wp-content/uploads/2009/02/wordpress-phpmyadmin.jpg" alt="wordpress-phpmyadmin" width="487" height="144" /></p>
<ul>
<li>Paste the following code in the window textarea. (Don’t forget to modify the password and username before executing it)</li>
</ul>
<blockquote><p>UPDATE &#8216;wp_users&#8217; SET &#8216;user_pass&#8217; = MD5(&#8216;PASSWORD&#8217;) WHERE &#8216;user_login&#8217; =&#8217;admin&#8217;;</p></blockquote>
<p>That&#8217;s it! Your password has been reset, and you should be able to login to your wordpress admin area once again.</p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/02/13/manually-reset-your-wordpress-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solution for: MySQL server has gone away at mysqlhotcopy line 528</title>
		<link>http://joshhighland.com/blog/2009/01/19/solution-for-mysql-server-has-gone-away-at-mysqlhotcopy-line-528/</link>
		<comments>http://joshhighland.com/blog/2009/01/19/solution-for-mysql-server-has-gone-away-at-mysqlhotcopy-line-528/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 18:43:18 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=501</guid>
		<description><![CDATA[
Recently I was backing up a large MySql database (several hundred megabytes), using the awesome MySqlHotCopy script, when I started getting the following error:
DBD::mysql::db do failed: MySQL server has gone away at mysqlhotcopy line 528.
I have no clue what that error means. mysqlhotcopyworked great on all of my other smaller databases. I did a little [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-500" title="mysql-logo" src="http://joshhighland.com/blog/wp-content/uploads/2009/01/mysql-logo.gif" alt="mysql-logo" width="218" height="151" /></p>
<p>Recently I was backing up a large MySql database (several hundred megabytes), using the awesome <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqlhotcopy.html">MySqlHotCopy</a> script, when I started getting the following error:</p>
<blockquote><p>DBD::mysql::db do failed: MySQL server has gone away at mysqlhotcopy line 528.</p></blockquote>
<p>I have no clue what that error means. mysqlhotcopyworked great on all of my other smaller databases. I did a little searching on my old friend google, and after sniffing around a bit, I came up with a resolution to the problem&#8230; the script was timing out, so I just had to increase the allowed time in the /etc/my.cnf file.</p>
<p>Here are the steps I took</p>
<blockquote><p>pico /etc/my.cnf</p></blockquote>
<blockquote><p>add these lines to the file:<br />
interactive_timeout = 3600<br />
wait_timeout = 3600</p></blockquote>
<blockquote><p>save file</p></blockquote>
<blockquote><p>/etc/init.d/mysqld restart</p></blockquote>
<p>I ran mysqlhotcopy again, and everything worked and the backup was made.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/01/19/solution-for-mysql-server-has-gone-away-at-mysqlhotcopy-line-528/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php sprintf + sql like</title>
		<link>http://joshhighland.com/blog/2008/07/06/php-sprintf-sql-like/</link>
		<comments>http://joshhighland.com/blog/2008/07/06/php-sprintf-sql-like/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 19:13:08 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=297</guid>
		<description><![CDATA[
Sometimes I do my best programming when I&#8217;m tired. Don&#8217;t ask me why, I just do. It&#8217;s a skill I picked up in college.
Being tired and producing good code wasn&#8217;t the case last night. I was trying to use the sprintf PHP function with a SQL &#8220;Like&#8221; statement. I made some dumb mistakes that tripped [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://joshhighland.com/blog/wp-content/uploads/2008/07/php_mysql_logo.jpg"><img class="alignnone size-medium wp-image-296" title="php and mysql" src="http://joshhighland.com/blog/wp-content/uploads/2008/07/php_mysql_logo.jpg" alt="" width="300" height="161" /></a></p>
<p>Sometimes I do my best programming when I&#8217;m tired. Don&#8217;t ask me why, I just do. It&#8217;s a skill I picked up in college.</p>
<p>Being tired and producing good code wasn&#8217;t the case last night. I was trying to use the sprintf PHP function with a SQL &#8220;Like&#8221; statement. I made some dumb mistakes that tripped me up for a while. Hopefully someone out there will find this post and help them not make the problems I made, sleepy or not!</p>
<p>Normally the LIKE is used in mysql like this:<strong><br />
<code>SELECT name FROM users WHERE name LIKE 'J%';</code></strong></p>
<p>That would get all names including: Josh, Jason, Jimi, etc.<br />
In a SQL Like statement the % is a wild card, so the command is to match everything starting with &#8220;J&#8221;</p>
<p>Now when you use the sprintf() function it looks kind like this:<br />
<strong><code>$query = sprintf("SELECT name FROM users WHERE name='%s'", $searchString);</code></strong><br />
The %s will be replaced with the value of $searchString</p>
<p>Trying to combined them is where I had some problems&#8230;.</p>
<p>At first I tried to do something like this:<br />
<code><strong>$query = sprintf("SELECT name FROM users WHERE name LIKE'%s'", $searchString);</strong><br />
</code>didnt return what I was looking for at all, it had no wild cards in it!</p>
<p>Then I tried this:<br />
<strong><code>$query = sprintf("SELECT name FROM users WHERE name LIKE'%s%'", $searchString);</code></strong><br />
didnt work either, this time it threw errors</p>
<p>But this worked great<strong><code><br />
$query =</code></strong><strong><code>sprintf("SELECT name FROM users WHERE name LIKE '%s'", $searchString . "%")</code>;</strong></p>
<p>So the moral of the story is, if you want to use a SQL Like statement, appent the wildcard for the Like statement to the string to be inserted by the sprintf funtion.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/07/06/php-sprintf-sql-like/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Select random records in a MySQL database</title>
		<link>http://joshhighland.com/blog/2007/07/16/select-random-records-in-a-mysql-database/</link>
		<comments>http://joshhighland.com/blog/2007/07/16/select-random-records-in-a-mysql-database/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 23:13:45 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/2007/07/16/select-random-records-in-a-mysql-database/</guid>
		<description><![CDATA[
Say you want to select some random records in a MySQL database. Here is a fast way to do it:

SELECT *
FROM tableName
WHERE conditions
ORDER BY Rand()

Using the Rand() function will randomly select the rows. You can limit the number of rows returned by using the LIMIT command
]]></description>
			<content:encoded><![CDATA[<p><img src='http://joshhighland.com/blog/wp-content/uploads/2007/07/mysql-logo.gif' alt='mysql-logo.gif' /><br />
Say you want to select some random records in a MySQL database. Here is a fast way to do it:</p>
<blockquote><p>
SELECT *<br />
FROM tableName<br />
WHERE conditions<br />
ORDER BY <strong>Rand()</strong>
</p></blockquote>
<p>Using the Rand() function will randomly select the rows. You can limit the number of rows returned by using the <a href="http://php.about.com/od/mysqlcommands/g/Limit_sql.htm">LIMIT command</a></p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2007/07/16/select-random-records-in-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cpanel broke mysqlhotcopy 1.22 but here is a fix!</title>
		<link>http://joshhighland.com/blog/2007/07/11/cpanel-broke-mysqlhotcopy-122-but-here-is-a-fix/</link>
		<comments>http://joshhighland.com/blog/2007/07/11/cpanel-broke-mysqlhotcopy-122-but-here-is-a-fix/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 00:03:38 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/2007/07/11/cpanel-broke-mysqlhotcopy-122-but-here-is-a-fix/</guid>
		<description><![CDATA[
Yesterday I logged into my server to back up my databases. I back up the mysql databases using a tool called &#8220;mysqlhotcoy&#8221;. It&#8217;s a handy perl application that copies the database files for easy restores, and it also works really quick when you run it.
I ran the mysqlhotcopy command as root, and was greeted with [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://joshhighland.com/blog/wp-content/uploads/2007/07/mysql-logo.gif' alt='mysql-logo.gif' /><br />
Yesterday I logged into my server to back up my databases. I back up the mysql databases using a tool called &#8220;mysqlhotcoy&#8221;. It&#8217;s a handy perl application that copies the database files for easy restores, and it also works really quick when you run it.</p>
<p>I ran the mysqlhotcopy command as root, and was greeted with an error similar to this:<br />
<code>Invalid db.table name 'foo.foo`.`bar'</code></p>
<p>um, no&#8230;. this table exists</p>
<p>I have cpanel installed on my server, a lot of server do. cpanel does updates to many application, mysqlhotcopy is one of them. It looks like my version of mysqlhotcopy was updated to 1.22, and there is some major problems with mysqlhotcopy 1.22.</p>
<p>I did some googeling and I found some people talking about the problem. I even found a quick patch for the problem. The problem comes from a host adding the username and an underscore before a database name (example: &#8220;<code>username_databasename.table</code>&#8220;). mysqlhotcopy only looks for <code>databasename.table </code></p>
<p><strong>The following patch instructions will fix mysqlhotcopy 1.22</strong></p>
<ul>
<li>Open the perl script for editing. It is located at <code>/usr/bin/mysqlhotcopy</code></li>
<li>find the following subroutine<br />
<blockquote><p>
sub get_list_of_tables {<br />
    my ( $db ) = @_;</p>
<p>    my $dbh = DBI-&gt;connect(&#8220;dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy&#8221;,<br />
			    $opt{user}, $opt{password},<br />
    {<br />
	RaiseError =&gt; 1,<br />
	PrintError =&gt; 0,<br />
	AutoCommit =&gt; 1,<br />
    });</p>
<p>    my @dbh_tables = eval { $dbh-&gt;tables() };<br />
    $dbh-&gt;disconnect();<br />
    return @dbh_tables;<br />
}
</p></blockquote>
</li>
<li>look for this line (mine was link 821):<br />
<blockquote><p>my @dbh_tables = eval { $dbh-&gt;tables() };</p></blockquote>
</li>
<li>immediately after that line add the following:<br />
<blockquote><p>map { s/^.*?\.//o } @dbh_tables</p></blockquote>
</li>
</ul>
<p>Here is my patched subroutine:</p>
<blockquote><p>sub get_list_of_tables {<br />
    my ( $db ) = @_;</p>
<p>    my $dbh = DBI-&gt;connect(&#8220;dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy&#8221;,<br />
			    $opt{user}, $opt{password},<br />
    {<br />
	RaiseError =&gt; 1,<br />
	PrintError =&gt; 0,<br />
	AutoCommit =&gt; 1,<br />
    });</p>
<p>    my @dbh_tables = eval { $dbh-&gt;tables() };<br />
    map { s/^.*?\.//o } @dbh_tables;<br />
    $dbh-&gt;disconnect();<br />
    return @dbh_tables;<br />
}
</p></blockquote>
<p>After I applied the patch, everything was back to working order.</p>
<p>Some people have <a href="http://sniptools.com/tipstricks/fix-mysqlhotcopy-broken-by-cpanel-upgrade">other approaches that would work also, like downgrading mysqlhotcopy all together</a>.</p>
<p>Personally, I think adding one line of code wasn&#8217;t that big of a deal to fix the program</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2007/07/11/cpanel-broke-mysqlhotcopy-122-but-here-is-a-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>experiments with MySQL FULLTEXT searching</title>
		<link>http://joshhighland.com/blog/2007/06/09/experiments-with-mysql-fulltext-searching/</link>
		<comments>http://joshhighland.com/blog/2007/06/09/experiments-with-mysql-fulltext-searching/#comments</comments>
		<pubDate>Sun, 10 Jun 2007 07:58:42 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/2007/06/09/experiments-with-mysql-fulltext-searching/</guid>
		<description><![CDATA[I just read a great article on FULLTEXT searching in a MySQL database
(http://www.onlamp.com/pub/a/onlamp/2003/06/26/fulltext.html)
I took a few minutes to run some of my own test using two of the largest text fields on the notPopular.com user profile table. I wanted to check out the results of a FULLTEXT search versus a LIKE query using real data [...]]]></description>
			<content:encoded><![CDATA[<p>I just read a great article on FULLTEXT searching in a MySQL database<br />
(<a href="http://www.onlamp.com/pub/a/onlamp/2003/06/26/fulltext.html">http://www.onlamp.com/pub/a/onlamp/2003/06/26/fulltext.html</a>)</p>
<p>I took a few minutes to run some of my own test using two of the largest text fields on the notPopular.com user profile table. I wanted to check out the results of a FULLTEXT search versus a LIKE query using real data in my database.</p>
<p>First I did a search using the LIKE clause looking for &#8220;xdeathstarx&#8221;</p>
<blockquote><p>
<code><br />
SELECT *<br />
FROM profiles<br />
WHERE approved =1<br />
AND<br />
(interests_general LIKE '%xdeathstarx%'<br />
OR<br />
interests_music LIKE '%xdeathstarx%')<br />
</code><br />
<em>Showing rows 0 &#8211; 29 (119 total, Query took 0.0763 sec)</em>
</p></blockquote>
<p>The query was fast, and took under a second to run</p>
<p>Next I created a FULLTEXT index on the &#8220;interests_general&#8221; and &#8220;interests_music&#8221; fields. It was really easy to do.</p>
<blockquote><p>
<code><br />
SELECT *<br />
FROM profiles<br />
WHERE approved =1<br />
AND MATCH (interests_general, interests_music)<br />
AGAINST ('xdeathstarx')<br />
</code><br />
<em>Showing rows 0 &#8211; 29 (119 total, Query took 0.0016 sec)</em>
</p></blockquote>
<p>Talk about fast! it took 0.0016 seconds</p>
<p>lets compare the differences:<br />
LIKE statements : 0.0763 sec<br />
FULLTEXT search : 0.0016 sec</p>
<p>hands down the FULLTEXT search won, it was about <strong>50x faster</strong>. If that isn&#8217;t instant results, I don&#8217;t know what are. Sure there will be more disk space used on the FULLTEXT index, but disk space is cheap, CPU cycles aren&#8217;t.</p>
<p>This makes me want to look more into optimizing the queries I am planning on using for the ever elusive notPop 2.0</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2007/06/09/experiments-with-mysql-fulltext-searching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
