<?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 with ·dotmanila &#187; MySQL</title>
	<atom:link href="http://dotmanila.com/blog/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmanila.com/blog</link>
	<description>Linux, Apache, PHP, MySQL Musings</description>
	<lastBuildDate>Sun, 01 Apr 2012 17:24:01 +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>Optimizing OR&#8217;ed WHERE Clauses Between JOIN&#8217;ed Tables</title>
		<link>http://dotmanila.com/blog/2012/04/optimizing-ored-where-clauses-between-joined-tables/</link>
		<comments>http://dotmanila.com/blog/2012/04/optimizing-ored-where-clauses-between-joined-tables/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 17:24:01 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=288</guid>
		<description><![CDATA[OR conditions are normally difficult to optimize when used on different columns, a pain when the columns are of range conditions and worst when done between 2 or more different tables. Look at my example below, the original query  is trying to find rows which conditions are based on columns from the JOIN&#8217;ed tables. mysql [...]]]></description>
			<content:encoded><![CDATA[<p>OR conditions are normally difficult to optimize when used on different columns, a pain when the columns are of range conditions and worst when done between 2 or more different tables. Look at my example below, the original query  is trying to find rows which conditions are based on columns from the JOIN&#8217;ed tables.</p>
<pre>mysql [localhost] {msandbox} (employees) &gt; EXPLAIN SELECT
    -&gt;      e.emp_no, birth_date, first_name,
    -&gt;      last_name, gender, hire_date,
    -&gt;      salary, from_date, to_date
    -&gt; FROM employees e
    -&gt; INNER JOIN salaries s ON (e.emp_no = s.emp_no)
    -&gt; WHERE e.hire_date BETWEEN '1990-06-01 00:00:00' AND '1990-07-01 00:00:00' OR
    -&gt;      s.from_date BETWEEN '1990-06-01 00:00:00' AND '1990-07-01 00:00:00'
    -&gt; ORDER BY e.emp_no, hire_date, from_date \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: e
         type: ALL
possible_keys: PRIMARY,hire_date
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 300547
        Extra: Using temporary; Using filesort
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: s
         type: ref
possible_keys: PRIMARY,emp_no,from_date
          key: PRIMARY
      key_len: 4
          ref: employees.e.emp_no
         rows: 4
        Extra: Using where
2 rows in set (0.00 sec)

mysql [localhost] {msandbox} (employees) &gt; SHOW CREATE TABLE employees \G
*************************** 1. row ***************************
       Table: employees
Create Table: CREATE TABLE `employees` (
  `emp_no` int(11) NOT NULL,
  `birth_date` date NOT NULL,
  `first_name` varchar(14) NOT NULL,
  `last_name` varchar(16) NOT NULL,
  `gender` enum('M','F') NOT NULL,
  `hire_date` date NOT NULL,
  PRIMARY KEY (`emp_no`),
  KEY `hire_date` (`hire_date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql [localhost] {msandbox} (employees) &gt; SHOW CREATE TABLE salaries \G
*************************** 1. row ***************************
       Table: salaries
Create Table: CREATE TABLE `salaries` (
  `emp_no` int(11) NOT NULL,
  `salary` int(11) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  PRIMARY KEY (`emp_no`,`from_date`),
  KEY `emp_no` (`emp_no`),
  KEY `from_date` (`from_date`),
  CONSTRAINT `salaries_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)</pre>
<p>If you look at the execution plan, the optimizer will always do a full table scan of the first table even though there is proper indexes on employees.hire_date and salaries.from_date. This is because it cannot know in advance which rows from the second table will match the rows from the second table, the OR conditions needs to match both tables. For the sake of brevity, observe what happens if I change the OR condition to AND instead.</p>
<pre>*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: e
         type: range
possible_keys: PRIMARY,hire_date
          key: hire_date
      key_len: 3
          ref: NULL
         rows: 2101
        Extra: Using where; Using temporary; Using filesort
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: s
         type: ref
possible_keys: PRIMARY,emp_no,from_date
          key: PRIMARY
      key_len: 4
          ref: employees.e.emp_no
         rows: 4
        Extra: Using where
2 rows in set (0.00 sec)</pre>
<p>As you can see, the optimizer now used the hire_date index in which for every matching row, there is about 4 rows matching on the second table.</p>
<p>Notice how many index reads and the full table scan the original query does. Imagine if you are working on a reporting query based on date ranges that has millions of rows for the first table, you might have to wait the next day for the results!</p>
<pre>mysql [localhost] {msandbox} (employees) &gt; SELECT
    -&gt;      e.emp_no, birth_date, first_name,
    -&gt;      last_name, gender, hire_date,
    -&gt;      salary, from_date, to_date
    -&gt; FROM employees e
    -&gt; INNER JOIN salaries s ON (e.emp_no = s.emp_no)
    -&gt; WHERE e.hire_date BETWEEN '1990-06-01 00:00:00' AND '1990-07-01 00:00:00' OR
    -&gt;      s.from_date BETWEEN '1990-06-01 00:00:00' AND '1990-07-01 00:00:00'
    -&gt; ORDER BY e.emp_no, hire_date, from_date;

b5abad9ac152d6289d4cc62b7d71fb83  -
28133 rows in set (1.39 sec)

mysql [localhost] {msandbox} (employees) &gt; NOPAGER; SHOW STATUS LIKE 'Handler%';
PAGER set to stdout
+----------------------------+---------+
| Variable_name              | Value   |
+----------------------------+---------+
...
| Handler_read_key           | 300025  |
| Handler_read_next          | 2844047 |
| Handler_read_prev          | 0       |
| Handler_read_rnd           | 28133   |
| Handler_read_rnd_next      | 328159  |
...
| Handler_write              | 28133   |
+----------------------------+---------+
15 rows in set (0.00 sec)</pre>
<p>Because the queries need to return rows matching both tables, we can rewrite it as UNION instead separating the WHERE clauses into 2 different SELECT queries like below.</p>
<pre>mysql [localhost] {msandbox} (employees) &gt; PAGER md5sum; FLUSH STATUS;
PAGER set to 'md5sum'
Query OK, 0 rows affected (0.00 sec)

mysql [localhost] {msandbox} (employees) &gt; (
    -&gt; SELECT
    -&gt;      e.emp_no, birth_date, first_name,
    -&gt;      last_name, gender, hire_date,
    -&gt;      salary, from_date, to_date
    -&gt; FROM employees e
    -&gt; INNER JOIN salaries s ON (e.emp_no = s.emp_no)
    -&gt; WHERE e.hire_date BETWEEN '1990-06-01 00:00:00' AND '1990-07-01 00:00:00'
    -&gt; )
    -&gt; UNION
    -&gt; (
    -&gt; SELECT e.emp_no, birth_date, first_name,
    -&gt;      last_name, gender, hire_date,
    -&gt;      salary, from_date, to_date
    -&gt; FROM employees e
    -&gt; INNER JOIN salaries s ON (e.emp_no = s.emp_no)
    -&gt; WHERE s.from_date BETWEEN '1990-06-01 00:00:00' AND '1990-07-01 00:00:00'
    -&gt; )
    -&gt; ORDER BY emp_no, hire_date, from_date;
b5abad9ac152d6289d4cc62b7d71fb83  -
28133 rows in set (0.14 sec)

mysql [localhost] {msandbox} (employees) &gt; NOPAGER; SHOW STATUS LIKE 'Handler%';
PAGER set to stdout
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
...
| Handler_read_key           | 11746 |
| Handler_read_next          | 31302 |
| Handler_read_prev          | 0     |
| Handler_read_rnd           | 28133 |
| Handler_read_rnd_next      | 28134 |
...
| Handler_write              | 29200 |
+----------------------------+-------+
15 rows in set (0.00 sec)</pre>
<p>With this approach, you are actually limiting the number of rows needed to be examined immediately before being JOINed. There is no real downsize with the new query, you just have to watch out that results from both SELECT&#8217;s does not grow too large, nearly the size of the total rows of both tables. In which case, you should not be doing the latter anyway i.e. trying to filter with big date ranges especially if you have very large dataset, instead you should implement summary tables that produces the results you need.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2012/04/optimizing-ored-where-clauses-between-joined-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Promote a MySQL Slave as Master with Zero Downtime</title>
		<link>http://dotmanila.com/blog/2012/02/promote-a-mysql-slave-as-master-with-zero-downtime/</link>
		<comments>http://dotmanila.com/blog/2012/02/promote-a-mysql-slave-as-master-with-zero-downtime/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 23:32:54 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=267</guid>
		<description><![CDATA[Whether you are upgrading, decommissioning or putting your current master server in maintenance &#8211; here&#8217;s a quick howto on promoting your slave server as new master for your application writes. This instructions (for my notes and the benefit of the researching readers) covers especially if you have multiple slaves attached to the master. Let&#8217;s assume that your [...]]]></description>
			<content:encoded><![CDATA[<p>Whether you are upgrading, decommissioning or putting your current master server in maintenance &#8211; here&#8217;s a quick howto on promoting your slave server as new master for your application writes. This instructions (for my notes and the benefit of the researching readers) covers especially if you have multiple slaves attached to the master. Let&#8217;s assume that your current active master is host A and the host you&#8217;d like to promote is host B.</p>
<ol>
<li><code>STOP SLAVE;</code> on all slaves including <strong>B</strong> that are attached to <strong>A</strong> directly.</li>
<li>Make sure that <code>log_slave_updates</code> and <code>bin_log</code> is <strong>ON</strong> on <strong>B</strong>.</li>
<li>If you are not taking <strong>A</strong> out of rotation and planning to switch back to it later as your master, you can configure it as slave of <strong>B</strong> forming a master-master pair. Simply take the <code>SHOW MASTER STATUS;</code> coordinates from <strong>B</strong> and use it to <code>CHANGE MASTER TO</code> for <strong>A</strong>.</li>
<li>Save <code>SHOW MASTER STATUS;</code> output from <strong>A</strong>.</li>
<li>Start replication on all the slaves that are attach to <strong>A</strong> again, but only until the coordinates you get from #3 using the syntax <code>START SLAVE UNTIL MASTER_LOG_FILE=&lt;log_file&gt;, MASTER_LOG_POS=&lt;log_pos&gt;</code>. This ensures that all slaves are caught up at exactly the same position so you can safely point them to replicate later to <strong>B</strong>.</li>
<li>Once all slaves have caught up on the same coordinates, now its time to reconfigure the rest of the slaves except <strong>B</strong> to replicate from <strong>B</strong>. Using the <code>SHOW MASTER STATUS;</code> coordinates from <strong>B</strong>, execute a <code>CHANGE MASTER TO MASTER_HOST=B ...</code></li>
<li>Now its time to fetch the remaining events from <strong>A</strong> to <strong>B</strong>, on <strong>B</strong>, <code>STOP SLAVE;</code> then <code>START SLAVE;</code> again, this time replication will retrieve all events since the coordinates we stopped at #4.</li>
<li>Once <strong>B</strong> and its slaves has caught up on replication, you can now point your application to send writes to <strong>B</strong>.</li>
<li>Lastly if you are taking <strong>A</strong> out of rotation but keeping it online, <code>RESET SLAVE;</code> on <strong>B</strong> after <code>Exec_Master_Log_Pos</code> and <code>Read_Master_Log_Pos</code> on <strong>B</strong> have stopped on the same position so that no further writes from <strong>A</strong> is replicated to <strong>B</strong>.</li>
</ol>
<p>Did I miss anything? Of course &#8211; not all failovers are the same, this guide is meant as an overview and must be reviewed to match your situation always. Comments welcome! <img src='http://dotmanila.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2012/02/promote-a-mysql-slave-as-master-with-zero-downtime/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Take Control of XtraBackup Backup Directory</title>
		<link>http://dotmanila.com/blog/2011/11/take-control-of-xtrabackup-backup-directory/</link>
		<comments>http://dotmanila.com/blog/2011/11/take-control-of-xtrabackup-backup-directory/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 13:23:30 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Backups]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[xtrabackup]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=227</guid>
		<description><![CDATA[When designing you backup strategy which involves using XtraBackup, it is often part of the job to be able to rotate backups not to fill the disks and not be able to take further backups. However, sometimes I&#8217;ve seen people how they can do this when XtraBackup creates its own timestamped directory (by default). Well, [...]]]></description>
			<content:encoded><![CDATA[<p>When designing you backup strategy which involves using XtraBackup, it is often part of the job to be able to rotate backups not to fill the disks and not be able to take further backups. However, sometimes I&#8217;ve seen people how they can do this when XtraBackup creates its own timestamped directory (by default). Well, here&#8217;s two.</p>
<p>1. After the backup, find the latest backup set on the backup directory using bash or whichever scripting language you are using, by default the resulting directory for new backup sets takes this sample format &#8217;2010-03-13_02-42-44&#8242;. Below is how you can achieve this with bash</p>
<p><code>CB=$(ls -1 | egrep '^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}$' | sort -n | head -n 1)</code></p>
<p>2. Use the &#8211;no-timestamp option of innobackupex to control the backup directories.</p>
<blockquote><p><code>--no-timestamp<br />
This option prevents creation of a time-stamped subdirectory of the<br />
BACKUP-ROOT-DIR given on the command line. When it is specified, the<br />
backup is done in BACKUP-ROOT-DIR instead.</code></p></blockquote>
<p>With this method, you will have to create the unique backup directories from your script, which in turn you would already know the resulting name you can use for prepare. You can easily generate one based on current date with the sample bash command below:</p>
<p><code>CURDATE=$(date +%Y-%m-%d)</code></p>
<p>This is only one essential part of a good backup procedure, I might blog on more. <img src='http://dotmanila.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2011/11/take-control-of-xtrabackup-backup-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solr DataImportHandler Converts TINYINT to Boolean</title>
		<link>http://dotmanila.com/blog/2011/08/solr-dataimporthandler-converts-tinyint-to-boolean/</link>
		<comments>http://dotmanila.com/blog/2011/08/solr-dataimporthandler-converts-tinyint-to-boolean/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 14:36:06 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Solr]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=189</guid>
		<description><![CDATA[When using Solr DataImportHandler with MySQL, the JDBC connection treats TINYINT(1) columns as BOOLEAN even if you have other values greater than. Most likely with a properly defined field of int type on your schema.xml you will get an error while indexing: SEVERE: java.lang.NumberFormatException: For input string: &#8220;true&#8221; This is a default behavior of Connector/J [...]]]></description>
			<content:encoded><![CDATA[<p>When using Solr DataImportHandler with MySQL, the JDBC connection treats TINYINT(1) columns as BOOLEAN even if you have other values greater than. Most likely with a properly defined field of int type on your schema.xml you will get an error while indexing:</p>
<blockquote><p>SEVERE: java.lang.NumberFormatException: For input string: &#8220;true&#8221;</p></blockquote>
<p>This is a default behavior of Connector/J on the property <strong>tinyInt1isBit</strong> documented <a href="http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html">here</a>. To fix this you should add <code>tinyInt1isBit=false</code> to your JDBC connection string.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2011/08/solr-dataimporthandler-converts-tinyint-to-boolean/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Maatkit Parallel Dump and Restore</title>
		<link>http://dotmanila.com/blog/2011/02/maatkit-parallel-dump-restor/</link>
		<comments>http://dotmanila.com/blog/2011/02/maatkit-parallel-dump-restor/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 03:18:11 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[maatkit]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=175</guid>
		<description><![CDATA[Maatkit&#8217;s mk-parallel-dump and mk-parallel-restore are great tools for quickly dumping and restoring your MySQL databases. I mean &#8220;quick&#8221; because it does this via user configurable number of threads. However, if you&#8217;re new to the tools, you may encounter several issues like &#8216;Out of memory!&#8217; or MySQL error &#8216;Lost connection to MySQL during query&#8230;&#8217;. Here are [...]]]></description>
			<content:encoded><![CDATA[<p>Maatkit&#8217;s mk-parallel-dump and mk-parallel-restore are great tools for quickly dumping and restoring your MySQL databases. I mean &#8220;quick&#8221; because it does this via user configurable number of threads. However, if you&#8217;re new to the tools, you may encounter several issues like &#8216;Out of memory!&#8217; or MySQL error &#8216;Lost connection to MySQL during query&#8230;&#8217;. Here are 2 tips to avoid them:</p>
<ol>
<li>Use the &#8211;chunk-size with data size option. If you have large tables (a couple of GB), dump and restore may simply consume a lot of RAM. Using &#8211;chunk-size like 20M or 50M you use a reasonable amount of memory. The tool manual also specifies more benefits when using chunks <a href="http://www.maatkit.org/doc/mk-parallel-dump.html#chunks" target="_blank">http://www.maatkit.org/doc/mk-parallel-dump.html#chunks</a></li>
<li>Make sure your server&#8217;s max_allowed_packet is large enough to accommodate large rows. When mk-parallel-restore fails with &#8220;Packet too large&#8221; error or any other error in that case, it simply emits the whole SQL statements onto the console making it hard to catch the actual error if your console buffer is too small in turn leaving you clueless if this is indeed your first time.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2011/02/maatkit-parallel-dump-restor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failed to read auto-increment value from storage engine</title>
		<link>http://dotmanila.com/blog/2010/11/failed-to-read-auto-increment-value-from-storage-engine/</link>
		<comments>http://dotmanila.com/blog/2010/11/failed-to-read-auto-increment-value-from-storage-engine/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 08:11:11 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[InnoDB]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=160</guid>
		<description><![CDATA[If you think the below error is trivial, there might just be two possible causes. ERROR 1467 (HY000) at line 1: Failed to read auto-increment value from storage engine Your table&#8217;s auto increment column datatype is too small i.e. MySQL is not able to generate more auto-increment values beyond TINYINT UNSIGNED because you are trying [...]]]></description>
			<content:encoded><![CDATA[<p>If you think the below error is trivial, there might just be two possible causes.</p>
<p><code>ERROR 1467 (HY000) at line 1: Failed to read auto-increment value from storage engine</code></p>
<ol>
<li>Your table&#8217;s auto increment column datatype is too small i.e. MySQL is not able to generate more auto-increment values beyond TINYINT UNSIGNED because you are trying to insert your 256th record.</li>
<li>It is a bug http://bugs.mysql.com/bug.php?id=36411</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2010/11/failed-to-read-auto-increment-value-from-storage-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mk-parallel-restore Outputs BLOB Data</title>
		<link>http://dotmanila.com/blog/2010/08/mk-parallel-restore-outputs-blob-data/</link>
		<comments>http://dotmanila.com/blog/2010/08/mk-parallel-restore-outputs-blob-data/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 01:54:55 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[BSD/Mac OSX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[maatkit]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=142</guid>
		<description><![CDATA[Recently I was playing around with the Maatkit tools specifically mk-parallel-dump and mk-parallel-restore for refreshing development database copies with production copies. A problem arises when BLOB data is being displayed on the console and transforming my shell prompt into gibberish and missing the results of the restore. Breaking the restore as soon as the BLOB [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was playing around with the Maatkit tools specifically mk-parallel-dump and mk-parallel-restore for refreshing development database copies with production copies. A problem arises when BLOB data is being displayed on the console and transforming my shell prompt into gibberish and missing the results of the restore. Breaking the restore as soon as the BLOB starts output, it was revealed that I was getting the &#8220;Got a packet bigger then &#8216;max_allowed_packet&#8217; bytes&#8221; error. After setting this variable to a reasonable value the restore went smoothly.</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2010/08/mk-parallel-restore-outputs-blob-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Default DATETIME Value &#8211; A Quick Rant</title>
		<link>http://dotmanila.com/blog/2009/11/mysql-default-datetime-value-a-quick-rant/</link>
		<comments>http://dotmanila.com/blog/2009/11/mysql-default-datetime-value-a-quick-rant/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 16:39:22 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[BSD/Mac OSX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[default datetime value]]></category>
		<category><![CDATA[now()]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=106</guid>
		<description><![CDATA[I was reviewing a year old code which I am adding a feature to. It so happened I came to a familiar issue about having two timestamp/datetime columns, one which should have the CURRENT_DATE / NOW() as default value and the other with an &#8216;ON UPDATE CURENT_TIMESTAMP&#8217;. Examine the simple structure below: CREATE TABLE `stories` [...]]]></description>
			<content:encoded><![CDATA[<p>I was reviewing a year old code which I am adding a feature to. It so happened I came to a familiar issue about having two timestamp/datetime columns, one which should have the CURRENT_DATE / NOW() as default value and the other with an &#8216;ON UPDATE CURENT_TIMESTAMP&#8217;. Examine the simple structure below:</p>
<pre class="brush: sql;ruler: true;">
CREATE TABLE `stories` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR( 255 ) NOT NULL ,
`text` TEXT NOT NULL ,
`creationdate` DATETIME NOT NULL ,
`lastupdate` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM</pre>
<p>When you want to store stories, you would also want to record when it was originally created as well track the last time it was updated. The problem here is that adding a `DEFAULT NOW()` clause will not work for the `CREATE TABLE` query above as it is not supported. So when your insert a new story you will have to explicitly add a `NOW()` function for the `creationdate` row so it will reflect the current date as creation date. This should&#8217;ve been a simple schema functionality, turns out after more than a year MySQL seems to ignore for some reason.</p>
<p>Go on have yourself a read here http://bugs.mysql.com/bug.php?id=27645</p>
<p>How about you, how many times have you have to work around this from your application code?</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2009/11/mysql-default-datetime-value-a-quick-rant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

