<?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>Tony Virelli - Web Developer - HTML, xHTML, PHP, MySQL, JavaScript&#187; SQL</title>
	<atom:link href="http://tonyvirelli.com/category/blog/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://tonyvirelli.com</link>
	<description>Tony Virelli - I share the information I have dealing with web design, technology, the internet and more</description>
	<lastBuildDate>Tue, 31 Jan 2012 14:57:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Speeding Up MySQL with Indexes</title>
		<link>http://tonyvirelli.com/slider/speeding-up-mysql-with-indexes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=speeding-up-mysql-with-indexes</link>
		<comments>http://tonyvirelli.com/slider/speeding-up-mysql-with-indexes/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:30:05 +0000</pubDate>
		<dc:creator>John Hass</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://tonyvirelli.com/?p=272</guid>
		<description><![CDATA[MySQL is an excellent database product and even though Oracle just bought out Sun, who bought out MySQL, Oracle still promised to keep up with MySQL patches and releases. (see more here)  This is great news for all us die hard MySQL and PHP guys, we no longer have to worry about giving up our [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL is an excellent database product and even though Oracle just bought out Sun, who bought out MySQL, Oracle still promised to keep up with MySQL patches and releases. (<a href="http://www.marketwatch.com/story/sun-climbs-after-oracle-presents-mysql-plan-2009-12-14">see more here</a>)  This is great news for all us die hard MySQL and PHP guys, we no longer have to worry about giving up our MySQL for something else (because you can have my PHP when you pry it from my cold dead fingers).  Though the question of the day is, when we get Millions of records how can we speed it up. Say for example I have a <em><strong>callrecord</strong></em> database that has a few things in it<br />
<span id="more-272"></span><br />
id|start_time|from_number|to_number|billsec</p>
<p>When I do a query by id everything is fast, but when I do a query by <strong><em>from_number</em></strong> everything is really slow, maybe even taking hours to complete. So lets create an index on the <em><strong>from_number</strong></em> to make it faster.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">CREATE INDEX full_from_number ON table_name (from_number);</pre></div></div>

<p>Now depending on the number of records you have this could take sometime. You can check on the status by opening another MySQL session and typing &#8220;show processlist&#8221;. This will show you what is currently going on in MySQL.  It may appear that your MySQL has froze, but it hasn&#8217;t. Be patient, I had a database take 18 hours before.</p>
<p>Why not index all fields?  This is a good question, but it is important to only index the fields that you perform a where on, creating an index, does slow the insert time some, but in my example with the <em><strong>callrecord</strong></em> database, I only filled it once a day and queried 100 times the next day, so creating extra indexes was a good thing to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://tonyvirelli.com/slider/speeding-up-mysql-with-indexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

