<?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>LAMP Tips! &#187; MySQL</title>
	<atom:link href="http://lamptips.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://lamptips.com</link>
	<description>Tips, tricks and (good) hacks</description>
	<lastBuildDate>Tue, 12 May 2009 22:04:48 +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>MySQL &#8220;How big are my databases?&#8221;</title>
		<link>http://lamptips.com/2008/04/mysql-how-big-are-my-databases/</link>
		<comments>http://lamptips.com/2008/04/mysql-how-big-are-my-databases/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 12:40:11 +0000</pubDate>
		<dc:creator>Dan S.</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Information]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://lamptips.com/?p=14</guid>
		<description><![CDATA[If you're like many of the MySQL users out there and do not have access to the MySQL command line, or perhaps you do have access to the MySQL command line and just want to know how to determine how big your databases and tables are, this is for you!

The INFORMATION_SCHEMA database contains a wealth [...]]]></description>
			<content:encoded><![CDATA[<p>If you're like many of the MySQL users out there and do not have access to the MySQL <strong>command line</strong>, or perhaps you do have access to the MySQL command line and just want to know how to determine how big your databases and tables are, this is for you!</p>
<p><span id="more-14"></span></p>
<p>The <strong>INFORMATION_SCHEMA</strong> database contains a wealth of information regarding your database(s), but is only available for MySQL 5.0 and up. One way I like to query the INFORMATION_SCHEMA database will return the <strong>Database | Table | Size</strong> for each table you've got. Here's what the SQL looks like:</p>
<pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> TABLE_SCHEMA <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'Database'</span>, TABLE_NAME <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'Table'</span>,
CONCAT<span style="color: #66cc66;">&#40;</span>ROUND<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>DATA_LENGTH + INDEX_LENGTH - DATA_FREE<span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">1024</span> / <span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">&quot; MB&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> Size <span style="color: #993333; font-weight: bold;">FROM</span> INFORMATION_SCHEMA.<span style="color: #993333; font-weight: bold;">TABLES</span>;</pre>
<p>Once you execute this SQL, you will get a nice list of your tables, along with their size, in MB. Feel free to adjust as necessary to retrieve additional data, or in different formats. If you have a format you really like, <strong>share it!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://lamptips.com/2008/04/mysql-how-big-are-my-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8220;Too Many Connections&#8221;</title>
		<link>http://lamptips.com/2008/04/mysql-too-many-connections/</link>
		<comments>http://lamptips.com/2008/04/mysql-too-many-connections/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 06:50:27 +0000</pubDate>
		<dc:creator>Dan S.</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://lamptips.com/?p=13</guid>
		<description><![CDATA[There isn't a day that goes by without someone, somewhere, reaching the maximum number of concurrent connections to their MySQL database. Generally, the solution is to increase this value; However this is not the best solution, nor does it alway help.

What MySQL users need to understand is that queries generally execute very fast. A busy [...]]]></description>
			<content:encoded><![CDATA[<p>There isn't a day that goes by without someone, somewhere, reaching the <strong>maximum</strong> number of concurrent <strong>connections</strong> to their MySQL database. Generally, the solution is to increase this value; However this is not the best solution, nor does it alway help.</p>
<p><span id="more-13"></span></p>
<p>What MySQL users need to understand is that queries generally execute <em>very fast</em>. A busy server should really never need more than 200 concurrent connections for any given user. The trick in solving this problem is to understand why it is happening. What is stopping your queries from executing fast?</p>
<p>Many times, the problem is as simple as your daily backups running. If your database is large and the backup takes 10 or 15 minutes to process, then all of the queries coming into the database will queue up and wait for the backup to finish. Processing 20 - 50 queries per second, it's not hard to do the math - your server could easily hit 200 connections queued waiting for the backup to finish - within seconds.</p>
<p>Solutions to this case can range from the simple, for instance, scheduling your backups to run at a time where you do not expect any traffic - to the more complex such as using<strong> replication </strong>as a backup aid. (Replication is something I will get into in later postings.)</p>
<p>Lastly, a backup of connections can always be caused from table<strong> locking </strong>issues, or slow queries (they take a long time). Running 1 complex query which takes 300 - 500 seconds to complete may indeed lock your table, preventing other queries from accessing the same data. You can always get a hint at what kind of queries are taking a long time to execute by logging the slowest of them. This "slow-query-log" can be enabled in your MySQL configuration file, commonly located at<em> /etc/my.cnf</em> by adding the following under the "[mysqld]" section:</p>
<p>log-slow-queries=/the/log/file/path</p>
<p>Where /the/log/file/path is wherever you want the file kept. You must restart MySQL after adding this setting.</p>
<p>When analyzing this file, it's always helpful to use "<strong>mysqldumpslow</strong>". I'm not going to give you all the answers, but if you want to learn how to use it to help analyze your slow query log, try:</p>
<p>mysqldumpslow --help</p>
]]></content:encoded>
			<wfw:commentRss>http://lamptips.com/2008/04/mysql-too-many-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
