<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0">

<channel>
	<title>Free Article Headquarters</title>
	<link>http://www.FreeArticleHQ.com</link>
	<description>Royalty Free Article for Content</description>
	<language>en-us</language>
	<category>Online Marketing</category>
	<category>Free Content</category>
	<copyright>Copyright 2006,Mukul Gupta</copyright>
	<webMaster>contact@sytesurge.com</webMaster>
	<lastBuildDate>Sun, 23 Nov 2008 06:20:28 GMT</lastBuildDate>	
	<item>
		<title>Improve the performance of your MySQL Server</title>
		<link>http://www.freearticlehq.com/view-article~a~103802.htm</link>
		<guid isPermaLink="true">http://www.freearticlehq.com/view-article~a~103802.htm</guid>
		<author>script@script2please.com (Mukul Gupta)</author>
		<description>by Mukul Gupta&lt;br&gt;Thursday, September 07, 2006&lt;br&gt;&lt;br&gt;MySQL is a rock solid, lighting fast database server which has been designed for two factors speed and performance. It is the Ferrari of databases: Light weight, fast and Built for the high speed tracks! &lt;BR&gt;&lt;BR&gt;I still hear an awful lot of stories from owners whose databases are running two slow. In my experience, the three main places to look for problems are: &lt;ol&gt;&lt;li&gt;Faulty Database Design &lt;/li&gt;&lt;li&gt;Bad Queries &lt;/li&gt;&lt;li&gt;Server factors&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;Faulty Database Design&lt;/b&gt;&lt;BR&gt;Proper database design is the single most important factor for the ensuring performance and maintainability of the database. Here is what you need to answer when designing a table: Can I reduce the size of data that each row will have? Here is what you can do: &lt;ol&gt;&lt;li&gt;Use unsigned numeric values when the      application will not store negative numbers. Like the &quot;quantity ordered&quot; of      an item in an ecommerce application is never going to be -$125. &lt;/li&gt;&lt;li&gt;Use Variable length values instead of      fixed length value i.e. used varchar instead of char.&lt;/li&gt;&lt;li&gt;Do not use unnecessarily large field      sizes. For most ecommerce application &lt;i&gt;&quot;unsigned      smallint&quot;&lt;/i&gt; is more than enough to store inventory count. A field      described as &lt;i&gt;&quot;unsigned smallint&quot;&lt;/i&gt;      can store a max value of 65535. &lt;/li&gt;&lt;li&gt;Don&apos;t ignore normalization; its helps      prevent unnecessary repetition of data. The part B of this is, don&apos;t      overuse normalization. If the table will not grow in size significantly,      there is no point in normalization. For example, if the user table has      just 20 rows (i.e. 20 employees in a company), all attempts of      normalization are wasted.  &lt;/li&gt;&lt;li&gt;Use Keys. Don&apos;t decide keys by &quot;The      customer id has to be indexed in the order table&quot;. If the order table is      being searched 90% of the times by &quot;order date&quot;, it makes more sense to      index &quot;order date&quot;. &lt;/li&gt;&lt;/ol&gt;Remember, how a table will be used should determine how it is designed. Spending time here will save years of frustration. &lt;BR&gt;&lt;BR&gt;&lt;b&gt;Bad Queries&lt;/b&gt;&lt;BR&gt;It sounds too good to be true but you wont believe the number of developers out there who completely suck at writing queries. There are two types of bad queries: &lt;BR&gt;&lt;BR&gt;a)    Unnecessary Queries: These are the queries that shouldn&apos;t have been made in the first place. The only way to avoid this is asking, &quot;Do I really need this data?&quot; &lt;BR&gt;&lt;BR&gt;b)    Inefficient Queries: These are the queries that do not use the underlying table structure or MySQL functions in the correct way. &lt;BR&gt;&lt;BR&gt;Here is a starting point to start looking at problem areas: &lt;ol&gt;&lt;li&gt;Unnecessary usage of &quot;&lt;i&gt;Select * &lt;/i&gt;&quot;statements when the      entire processing is being done on a single column. The more data is fetched      from the server the more work MySQL has to do and more bandwidth it takes.      &lt;/li&gt;&lt;li&gt;Using sub-query instead of a join. On a      properly designed database, joins are incredibly fast. Using sub-queries      just shows a lack of knowledge. &lt;/li&gt;&lt;li&gt;Improper use of Keys. This is especially      valid for range checks. Remember to use the &quot;&lt;i&gt;Explain&lt;/i&gt;&quot; statement to check the usage of keys and then use the      &quot;&lt;i&gt;use key&lt;/i&gt;&quot; statement in your &quot;&lt;i&gt;where&lt;/i&gt;&quot; clauses to force key usage. &lt;/li&gt;&lt;/ol&gt;&lt;b&gt;Server Factors&lt;/b&gt;&lt;BR&gt;Everything done correctly, there still may be some server factors that may be causing the system to be slow. These are: &lt;ol&gt;&lt;li&gt;Hardware related &lt;/li&gt;&lt;li&gt;Server configuration related &lt;/li&gt;&lt;/ol&gt;Here is what you can do about the hardware: &lt;ol&gt;&lt;li&gt;The more RAM is on the system the better      it is. MySQL frequently fetches data from the RAM and more the RAM is on      the system, the better it is. &lt;/li&gt;&lt;li&gt;Buy the fastest possible RAM! A slower      RAM is just irony. &lt;/li&gt;&lt;li&gt;Once you are settled with the RAM size      and speed, look for processing speed. MySQL can use multiple processors. &lt;/li&gt;&lt;/ol&gt;Once you are satisfied with the hardware, there are a set of variables in &quot;my.cnf&quot; that you must look at: &lt;BR&gt;&lt;BR&gt;a)    &lt;i&gt;key_buffer_size&lt;/i&gt;: This describes the memory available to store the index keys. The default is 8 MB but you can set it to 25% of the RAM.&lt;BR&gt;&lt;BR&gt;b)    &lt;i&gt;query_cache_size&lt;/i&gt;: This value is by default 0. if you have a lot of repeating queries like in reporting applications etc, make sure you set this value high. &lt;BR&gt;&lt;BR&gt;c)    &lt;i&gt;table_open_cache: &lt;/i&gt;This determines the number of table descriptors that MySQL will keep in the cache. The default value is 64. But, if you have 100 users accessing a table concurrently then this value should atleast be 100. You also have to take into considerations joins etc. Thus, this value should also be kept high.&lt;BR&gt;&lt;BR&gt; I hope this article will take one step further in unlocking the mystery of slow servers and help solve some of the problems.&lt;br&gt;&lt;br&gt;&lt;b&gt;About the Author&lt;/b&gt;&lt;br&gt;&lt;br&gt;Mukul Gupta is the CMO of Indus Net Technologies, an India based Internet Consulting firm which specializes in Opensource solutions. You can reach him at script@script2please.com or visit http://www.script2please.com

&lt;br&gt;&lt;br&gt;&lt;font size=1 face=arial&gt;Get &lt;A HREF=&quot;http://www.freearticlehq.com/&quot;&gt;Royalty Free Articles&lt;/a&gt; for your web site, newsletter, or ezine at the &lt;A HREF=&quot;http://www.freearticlehq.com/&quot;&gt;Free Article Headquarters&lt;/A&gt;&lt;/font&gt;</description>
		<category>Software &amp; Programming</category>
		<pubDate>Thu, 7 Sep 2006 15:41:32 GMT</pubDate>
	</item>
</channel>
</rss>
