<?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>VT's Tech Blog &#187; Databases</title> <atom:link href="http://blogs.vinuthomas.com/category/programming/databases/feed/" rel="self" type="application/rss+xml" /><link>http://blogs.vinuthomas.com</link> <description>My Tech Discovery Blog on PHP, Ajax, Security and Web 2.0</description> <lastBuildDate>Tue, 24 Aug 2010 15:59:19 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>mysqlind_qc: Client Side Caching for MySQL extensions for PHP</title><link>http://blogs.vinuthomas.com/2010/06/29/mysqlind_qc-client-side-caching-for-mysql-extensions-for-php/</link> <comments>http://blogs.vinuthomas.com/2010/06/29/mysqlind_qc-client-side-caching-for-mysql-extensions-for-php/#comments</comments> <pubDate>Tue, 29 Jun 2010 07:50:02 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[extension]]></category> <category><![CDATA[mysql]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=4954</guid> <description><![CDATA[Here's something in the making, a PHP extension which caches MySQL queries irrespective of the extension being used. It's a plugin for mysqlind, the native MySQL driver for PHP called  mysqlind_qc. This currently requires PHP 5.3.3-dev which is still in development.]]></description> <content:encoded><![CDATA[<p><a href="http://blogcdn.vinuthomas.com/wp-content/uploads/2010/06/mysql_logo.png" rel="lightbox[4954]"><img class="size-full wp-image-542 alignright" title="MySQL " src="http://blogcdn.vinuthomas.com/wp-content/uploads/2010/06/mysql_logo.png" alt="" width="200" height="103" /></a></p><p>Here&#8217;s something in the making, a PHP extension which caches MySQL queries irrespective of the extension being used. It&#8217;s a plugin for <a href="http://dev.mysql.com/downloads/connector/php-mysqlnd/">mysqlnd</a>, the native MySQL driver for PHP called  mysqlnd_qc. This currently requires PHP 5.3.3-dev which is still in development.</p><p>The extension allows caching buffered queries through mysql_query and mysqli_query. It allows cache-invalidation though TTL or a user defined callback. This extension is still in the protoype stage right now and will evolve as the project progresses.</p><p>The Query Cache is implemented as a PHP extension. It is written in C and operates &#8220;under the hood&#8221; of PHP. During the start up of the PHP interpreter it gets registered as a mysqlnd plugin to replaces selected mysqlnd methods.</p><blockquote><p>At PHP run time it proxies queries send from mysqlnd/PHP to the MySQL server. If a query string starts with the SQL hint (/*qc=on*/) to enable caching of it and the query is not cached (Cache miss), the query cache plugin will record the raw wire protocol data send from MySQL to PHP to answer the query. The query cache records the wire protocol data in its cache medium and replays it, if still valid, on a cache hit.</p><p>Note that the query cache does not hold decoded result sets consisting of zvals (C struct representing a PHP variable). It stores the raw wire data of the MySQL client server protocol. In case of a cache hits, mysqlnd still needs to decode the cached raw wire data into PHP variables before passing the result to the user space. This approach has one major advantage: simplicity.</p></blockquote><p>You can get more information and installation instructions over at the <a href="http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP">MySQLND Query Cache Project page at Mysql Forge</a>.</p><p>Check out this slide which gives you more information about this extension:</p><div id="__ss_4525028" style="width: 425px;"><strong><a title="Built-in query caching for all PHP MySQL extensions/APIs" href="http://www.slideshare.net/nixnutz/buildin-query-caching-for-all-php-mysql-extensionsapis">Built-in query caching for all PHP MySQL extensions/APIs</a></strong><object id="__sse4525028" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mysqlndquerycacheprototype-100617062420-phpapp01&amp;stripped_title=buildin-query-caching-for-all-php-mysql-extensionsapis" /><param name="name" value="__sse4525028" /><param name="allowfullscreen" value="true" /><embed id="__sse4525028" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mysqlndquerycacheprototype-100617062420-phpapp01&amp;stripped_title=buildin-query-caching-for-all-php-mysql-extensionsapis" name="__sse4525028" allowscriptaccess="always" allowfullscreen="true"></embed></object></p><div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/nixnutz">Ulf Wendel</a>.</div></div><div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_c.png?x-id=97f0e5db-2fe9-4768-a02e-773c38987487" alt="Enhanced by Zemanta" /></a><span class="zem-script more-info pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2010/06/29/mysqlind_qc-client-side-caching-for-mysql-extensions-for-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>A Benchmark of Opensource Search Engines</title><link>http://blogs.vinuthomas.com/2009/07/07/a-benchmark-of-opensource-search-engines/</link> <comments>http://blogs.vinuthomas.com/2009/07/07/a-benchmark-of-opensource-search-engines/#comments</comments> <pubDate>Tue, 07 Jul 2009 16:30:24 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Tech Stuff]]></category> <category><![CDATA[benchmarks]]></category> <category><![CDATA[lucene]]></category> <category><![CDATA[search]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=1008</guid> <description><![CDATA[I&#8217;ve always wanted to know how the various opensource search engines performed when running head to head with each other. I&#8217;ve personally not had the time nor patience to setup such a benchmark. Luckily Vik Singh has done just that and blogged the results of the benchmark. He&#8217;s benchmarked the latest versions of Lucene, sqlite, [...]]]></description> <content:encoded><![CDATA[<div class="zemanta-img zemanta-action-dragged" style="margin: 1em; display: block;"><div><dl class="wp-caption alignright" style="width: 250px;"><dt class="wp-caption-dt"><a href="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/07/3696470203_93e8a02159_m.jpg" rel="lightbox[1008]"><img title="This is gonna be a long hike (and an announcem..." src="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/07/3696470203_93e8a02159_m.jpg" alt="This is gonna be a long hike (and an announcem..." width="240" height="159" /></a></dt><dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;"></dd></dl></div></div><p>I&#8217;ve always wanted to know how the various opensource search engines performed when running head to head with each other. I&#8217;ve personally not had the time nor patience to setup such a benchmark. Luckily <a href="http://zooie.wordpress.com">Vik Singh</a> has done just that and blogged the results of the benchmark.</p><p>He&#8217;s benchmarked the latest versions of <a class="zem_slink" title="Lucene" rel="homepage" href="http://lucene.apache.org">Lucene</a>, <a class="zem_slink" title="SQLite" rel="homepage" href="http://www.sqlite.org/">sqlite</a>, <a class="zem_slink" title="Xapian" rel="homepage" href="http://xapian.org/">Xapian</a>, <a class="zem_slink" title="Zettair" rel="wikipedia" href="http://en.wikipedia.org/wiki/Zettair">zettair</a> and sphinx while indexing twitter messages (968,937 tweets to be exact) and  Medical data sets. I was not too surprised when Lucene came up as a winner from these benchmarks <img src='http://blogcdn.vinuthomas.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><a href="http://zooie.wordpress.com/2009/07/06/a-comparison-of-open-source-search-engines-and-indexing-twitter/">Read the Blog post by Vik to get the details of the benchmarks</a>.</p><div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/92b7c575-bfa2-468c-a1e1-f95eb7be1034/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=92b7c575-bfa2-468c-a1e1-f95eb7be1034" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2009/07/07/a-benchmark-of-opensource-search-engines/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Generate data for Database testing</title><link>http://blogs.vinuthomas.com/2009/02/10/generatedata-for-database-testing/</link> <comments>http://blogs.vinuthomas.com/2009/02/10/generatedata-for-database-testing/#comments</comments> <pubDate>Tue, 10 Feb 2009 14:55:07 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[Scripts]]></category> <category><![CDATA[Database]]></category> <category><![CDATA[mysql]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=767</guid> <description><![CDATA[Image by lilit via Flickr How often have you tested your application on your local machine and had it run properly, but when you deploy it and the database starts getting filled up, you start noticing performance problems? Here&#8217;s something you can use to test out your application with databases which are not empty &#8211; [...]]]></description> <content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;"><div><dl class="wp-caption alignright" style="width: 250px;"><dt class="wp-caption-dt"><a href="http://www.flickr.com/photos/29492436@N00/63853597"><img title="(My)SQL geek" src="http://farm1.static.flickr.com/28/63853597_80e3a3566c_m.jpg" alt="(My)SQL geek" width="240" height="180"/></a></dt><dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image by <a href="http://www.flickr.com/photos/29492436@N00/63853597">lilit</a> via Flickr</dd></dl></div></div><p>How often have you tested your application on your local machine and had it run properly, but when you deploy it and the database starts getting filled up, you start noticing performance problems?<br /> Here&#8217;s something you can use to test out your application with databases which are not empty &#8211; <a href="http://www.generatedata.com/#about">generatedata.com </a>allows you to define your table structure and the type of data to fill it with. You can export the generated data as SQL (MySQL and Oracle are supported currently)&nbsp; insert statements or csv which you can import into your databases. The online version allows you to export 200 rows of generated data. If you want larger datasets to be generated, you can <a href="http://www.generatedata.com/#download">download the datagenerator script</a> and run it on your own server.</p><p>The best part of the script is instead of generating totally random string or numeric data, you some some semi-realistic data which can be used for testing.</p><p>Here&#8217;s a sample form I created on the site (click on the image to enlarge):</p><p><a href="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/02/filled-form-gd.png" rel="lightbox[767]"><img class="aligncenter size-medium wp-image-769" title="An Example form -  generatedata.com" src="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/02/filled-form-gd-300x70.png" alt="An Example form -  generatedata.com" width="300" height="70"/></a></p><p>The SQL generated from this form:</p><div class="wp_codebox"><table><tr id="p7672"><td class="code" id="p767code2"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> myTable <span style="color: #FF00FF;">&#40;</span>
  id <span style="color: #999900; font-weight: bold;">mediumint</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">8</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #FF9900; font-weight: bold;">unsigned</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">auto_increment</span><span style="color: #000033;">,</span>
  id <span style="color: #999900; font-weight: bold;">MEDIUMINT</span> <span style="color: #990099; font-weight: bold;">default</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
  name <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">255</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">default</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
  city <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">default</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
  country <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">default</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
  dateofjoining <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">default</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
  <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`id`</span><span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">TYPE</span><span style="color: #CC0099;">=</span>MyISAM <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #CC0099;">=</span><span style="color: #008080;">1</span><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'1'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Inez'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Muncie'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Grenada'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-04-19 12:55:49'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'2'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Reese'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Washington'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Suriname'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-10-17 01:28:15'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'3'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Hope'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Edina'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Guyana'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2008-02-22 10:17:55'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'4'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Cameron'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Sister Bay'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Malaysia'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2008-02-21 01:38:18'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'5'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Zephr'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Lebanon'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Syrian Arab Republic'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2008-12-09 21:40:04'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'6'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Byron'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Indio'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Afghanistan'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-03-15 08:50:17'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'7'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Carol'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Bay St. Louis'</span><span style="color: #000033;">,</span><span style="color: #008000;">'British Indian Ocean Territory'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-04-16 04:57:43'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'8'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Latifah'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Geneva'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Albania'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-08-25 00:14:26'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'9'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Nina'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Fall River'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Solomon Islands'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-01-03 21:45:51'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> myTable <span style="color: #FF00FF;">&#40;</span>id<span style="color: #000033;">,</span>name<span style="color: #000033;">,</span>city<span style="color: #000033;">,</span>country<span style="color: #000033;">,</span>dateofjoining<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">VALUES</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'10'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Jorden'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Ardmore'</span><span style="color: #000033;">,</span><span style="color: #008000;">'Latvia'</span><span style="color: #000033;">,</span><span style="color: #008000;">'2009-01-20 19:31:36'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></td></tr></table></div><p>Get more information at: <a href="http://www.generatedata.com/">generatedata.com</a></p><p style="text-align: center;"><a href="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/02/generatedata1.png" rel="lightbox[767]"><img class="aligncenter size-medium wp-image-768" title="generatedata.com" src="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/02/generatedata1-300x187.png" alt="generatedata.com" width="300" height="187"/></a></p><div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/b72abd17-c8a6-42c6-ba04-30130fbbb69b/" title="Zemified by Zemanta"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=b72abd17-c8a6-42c6-ba04-30130fbbb69b" alt="Reblog this post [with Zemanta]"/></a></div> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2009/02/10/generatedata-for-database-testing/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Create a Storage engine for MySQL using PHP</title><link>http://blogs.vinuthomas.com/2008/12/30/create-a-storage-engine-for-mysql-using-php/</link> <comments>http://blogs.vinuthomas.com/2008/12/30/create-a-storage-engine-for-mysql-using-php/#comments</comments> <pubDate>Tue, 30 Dec 2008 12:45:12 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[General Stuff]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=721</guid> <description><![CDATA[An interesting article I came across today by Johannes Schlüter, who works in the one of the MySQL teams in Sun. He&#8217;s done some interesting work writing a MySQL Storage Engine using PHP. His article shows how to do some basic using this. MySQL 5.1 has a plugin interface to easily add storage engines. PHP [...]]]></description> <content:encoded><![CDATA[<div class="mceTemp mceIEcenter"><dl id="attachment_542" class="wp-caption aligncenter" style="width: 210px;"><dt class="wp-caption-dt" style="text-align: center;"><img class="size-full wp-image-542" title="MySQL " src="http://blogcdn.vinuthomas.com/wp-content/uploads/2008/07/mysql_logo.png" alt="MySQL Logo" width="200" height="103" /></dt></dl></div><p>An interesting article I came across today by Johannes Schlüter, who works in the one of the MySQL teams in Sun. He&#8217;s done some interesting work writing a MySQL Storage Engine using PHP. His article shows how to do some basic using this.</p><blockquote><p>MySQL 5.1 has a plugin interface to easily add storage engines. PHP can easily embedded into other applications.  So why not combine these two things? &#8211; Writing a MySQL Storage Engine which reads data by calling a PHP script.</p></blockquote><p>This article is interesting because of the uses which come up when you can create custom Storage Engines using PHP. An interesting usecase for this is in creating test cases, where you can feed the data for a query from PHP and trap the activities on the database.</p><p>Head out and read this article and take a look at the code at his blog: <a href="http://schlueters.de/blog/archives/96-MySQL-Storage-Engine-based-on-PHP.html">MySQL Storage Engine based on PHP</a></p><p>You can also take a look at the<a href="https://launchpad.net/mysql-php-storage"> Launchpad page for this project</a>.</p><p>The following output and code is from the Lauchpad page which shows the PHP code and the queries in MySQL:</p><div class="wp_codebox"><table><tr id="p7215"><td class="code" id="p721code5"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #000000; font-weight: bold;">extends</span> ArrayIterator implements MySQLStorage_Writable<span style="color: #339933;">,</span> MySQLStorage_Updatable<span style="color: #339933;">,</span> MySQLStorage_Deletable <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> write<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> delete<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> create_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> open_table<span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Test<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'foo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'bar'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div><p>Sample Queries run on this engine:</p><div class="wp_codebox"><table><tr id="p7216"><td class="code" id="p721code6"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> php_write<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> id   <span style="color: #CC0099;">|</span> val  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> <span style="color: #008080;">1</span>    <span style="color: #CC0099;">|</span>  foo <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> <span style="color: #008080;">2</span>    <span style="color: #CC0099;">|</span> bar  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">2</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> php_write <span style="color: #FF00FF;">&#40;</span>id <span style="color: #999900; font-weight: bold;">int</span><span style="color: #000033;">,</span> val <span style="color: #000099;">CHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">3</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">ENGINE</span><span style="color: #CC0099;">=</span>PHP<span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">0</span> rows affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">UPDATE</span> php_write <span style="color: #990099; font-weight: bold;">SET</span> val <span style="color: #CC0099;">=</span> <span style="color: #008000;">'baz'</span> <span style="color: #990099; font-weight: bold;">WHERE</span> id <span style="color: #CC0099;">=</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">1</span> row affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.02</span> sec<span style="color: #FF00FF;">&#41;</span>
Rows matched: <span style="color: #008080;">1</span> Changed: <span style="color: #008080;">1</span> <span style="color: #990099; font-weight: bold;">Warnings</span>: <span style="color: #008080;">0</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">DELETE</span> <span style="color: #990099; font-weight: bold;">FROM</span> php_write <span style="color: #990099; font-weight: bold;">WHERE</span> id <span style="color: #CC0099;">=</span> <span style="color: #008080;">2</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">1</span> row affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.02</span> sec<span style="color: #FF00FF;">&#41;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">INSERT</span> <span style="color: #990099; font-weight: bold;">INTO</span> php_write <span style="color: #990099; font-weight: bold;">VALUES</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">3</span><span style="color: #000033;">,</span> <span style="color: #008000;">'bar'</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
Query OK<span style="color: #000033;">,</span> <span style="color: #008080;">1</span> row affected <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> php_write<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> id   <span style="color: #CC0099;">|</span> val  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #CC0099;">|</span> <span style="color: #008080;">1</span>    <span style="color: #CC0099;">|</span> baz  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> <span style="color: #008080;">3</span>    <span style="color: #CC0099;">|</span> bar  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+------+------+</span>
<span style="color: #008080;">2</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.01</span> sec<span style="color: #FF00FF;">&#41;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2008/12/30/create-a-storage-engine-for-mysql-using-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Scrawlr &#8211; Scanner for SQL Injection</title><link>http://blogs.vinuthomas.com/2008/06/29/scrawlr-scanner-for-sql-injection/</link> <comments>http://blogs.vinuthomas.com/2008/06/29/scrawlr-scanner-for-sql-injection/#comments</comments> <pubDate>Sun, 29 Jun 2008 06:57:28 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Scrawlr]]></category> <category><![CDATA[SQL Injection]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=528</guid> <description><![CDATA[Scrawlr is short for SQL Injector and Crawler, a tool developed by the HP Web Security Research Group in coordination with the Microsoft Security Response Center in response to the widespread SQL injection attacks on the web. &#8220;Scrawlr will crawl a website while simultaneously analyzing the parameters of each individual web page for SQL Injection [...]]]></description> <content:encoded><![CDATA[<p>Scrawlr is short for SQL Injector and Crawler, a tool developed by the HP Web Security Research Group in coordination with the Microsoft Security Response Center in response to the widespread SQL injection attacks on the web.</p><blockquote><p>&#8220;Scrawlr will crawl a website while simultaneously analyzing the parameters of each individual web page for <a class="zem_slink" title="SQL injection" rel="wikipedia" href="http://en.wikipedia.org/wiki/SQL_injection">SQL Injection</a> vulnerabilities. Scrawlr is lightning fast and uses our intelligent engine technology to dynamically craft SQL Injection attacks on the fly. It can even provide proof positive results by displaying the type of backend database in use and a list of available table names. There is no denying you have SQL Injection when I can show you table names!&#8221;</p></blockquote><p>Key Features of Scrawlr include:</p><ul><li>Identify Verbose SQL Injection vulnerabilities in URL parameters</li><li>Can be configured to use a Proxy to access the web site</li><li>Will identify the type of SQL server in use</li><li>Will extract table names (verbose only) to guarantee no false positives</li></ul><p style="text-align: center;"><img class="size-medium wp-image-530" title="Scrawlr - Sql Injection Scanner" src="http://blogcdn.vinuthomas.com/wp-content/uploads/2009/07/scrawlr-300x231.jpg" alt="" width="300" height="231" /></p><p>Scrawlr which is a free tool has a few limitations which are it&#8217;s crawl only upto 1500 pages, doesn&#8217;t support Blind SQL injection and will not test for Post parameters for SQL injection. Overall even with these limitations, it&#8217;s still a useful tool to check your sites to see if you&#8217;re safe from SQL injections.</p><p><strong>Links:<br /> </strong><a href="https://download.spidynamics.com/products/scrawlr/">Download Scrawlr</a><br /> <a href="http://www.communities.hp.com/securitysoftware/forums/198.aspx">Scrawlr Forum</a><a href="http://www.communities.hp.com/securitysoftware/forums/198.aspx"></a></p><p>via: <a href="http://www.communities.hp.com/securitysoftware/blogs/spilabs/archive/2008/06/23/finding-sql-injection-with-scrawlr.aspx">communities.hp.com</a></p><div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/597d21ee-2d3e-47d9-b370-33792f4e717c/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_a.png?x-id=597d21ee-2d3e-47d9-b370-33792f4e717c" alt="Zemanta Pixie" /></a></div> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2008/06/29/scrawlr-scanner-for-sql-injection/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>MySQL Error: 1062 Duplicate entry &#8217;0&#8242; for key 1</title><link>http://blogs.vinuthomas.com/2008/06/18/mysql-error-1062-duplicate-entry-0-for-key-1/</link> <comments>http://blogs.vinuthomas.com/2008/06/18/mysql-error-1062-duplicate-entry-0-for-key-1/#comments</comments> <pubDate>Wed, 18 Jun 2008 09:39:16 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[Database]]></category> <category><![CDATA[FAQs  Help  and Tutorials]]></category> <category><![CDATA[mysql]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=524</guid> <description><![CDATA[Here&#8217;s a problem we had come across today. Whenever we tried inserting data into a certain table, MySQL kept throwing up the following error: mySQL error: 1062 Duplicate entry '0' for key 1 After scratching our heads over this one, we tried to alter the table to set the autoincrement field to the next number [...]]]></description> <content:encoded><![CDATA[<p><a href="http://blogcdn.vinuthomas.com/wp-content/uploads/2008/07/mysql_logo.png" rel="lightbox[524]"><img class="alignright size-full wp-image-542" title="MySQL " src="http://blogcdn.vinuthomas.com/wp-content/uploads/2008/07/mysql_logo.png" alt="MySQL Logo" width="200" height="103" /></a>Here&#8217;s a problem we had come across today. Whenever we tried inserting data into a certain table, MySQL kept throwing up the following error:</p><p><code>mySQL error: 1062<br /> Duplicate entry '0' for key 1</code></p><p>After scratching our heads over this one, we tried to alter the table to set the autoincrement field to the next number and even that failed to fix the problem. Then hunting around the web, we found the cause of this problem. It seems that Mysql throws this error because the field type of the auto increment field is not large enough to hold the next value, so it tries to wraps the count back to &#8217;0&#8242; where the is already a record with that value.</p><p>We changed the field from <em>int</em> to <em>unsigned bigint</em> which fixed the problem for us. So if you face the same problem, check if your autoincrement field has maxed the datatype for that field.</p><fieldset class="zemanta-related"><legend>Other Interesting MySQL articles</legend><ul class="zemanta-article-ul"><li class="zemanta-article-ul-li"><a title="Open in new window" href="http://alexking.org/blog/2008/03/06/mysql-latin1-utf8-conversion">Fixing a MySQL Character Encoding Mismatch</a> [via Zemanta]</li><li class="zemanta-article-ul-li"><a title="Open in new window" href="http://blogs.vinuthomas.com/2008/06/02/mysql-tip-ordering-by-date-stored-in-a-varchar-field/">MySQL Tip &#8211; Ordering by Date stored in a varchar field</a></li><li class="zemanta-article-ul-li"><a title="Open in new window" href="http://www.linux.com/feature/127055">Using MySQL as a filesystem</a> [via Zemanta]</li><li class="zemanta-article-ul-li"><a title="Open in new window" href="http://www.regdeveloper.co.uk/2008/04/16/mysql_development_roadmap/">MySQL to fortify defenses with Citadel</a> [via Zemanta]</li></ul></fieldset><div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/17f01e4c-8d05-4310-831e-164727b17a7e/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=17f01e4c-8d05-4310-831e-164727b17a7e" alt="Zemanta Pixie" /></a></div> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2008/06/18/mysql-error-1062-duplicate-entry-0-for-key-1/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>MySQL Tip &#8211; Ordering by Date stored in a varchar field</title><link>http://blogs.vinuthomas.com/2008/06/02/mysql-tip-ordering-by-date-stored-in-a-varchar-field/</link> <comments>http://blogs.vinuthomas.com/2008/06/02/mysql-tip-ordering-by-date-stored-in-a-varchar-field/#comments</comments> <pubDate>Mon, 02 Jun 2008 15:33:26 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[FAQs]]></category> <category><![CDATA[Help]]></category> <category><![CDATA[mysql]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/?p=508</guid> <description><![CDATA[How do you sort a varchar field which has the dates stored in it? If you try the usual order by on the varchar fields you&#8217;ll have trouble with the sort order, since MySQL will order this field like a varchar and you will surely have problems with dates being sorted this way. Take the [...]]]></description> <content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; float: right;"><a href="http://en.wikipedia.org/wiki/Image:MySQL.svg" target="_blank"><img style="border: medium none; display: block;" src="http://upload.wikimedia.org/wikipedia/en/thumb/6/62/MySQL.svg/202px-MySQL.svg.png" alt="MySQL Enterprise Server" /></a></div><p>How do you sort a varchar field which has the dates stored in it? If you try the usual order by on the varchar fields you&#8217;ll have  trouble with the sort order, since MySQL will order this field like a varchar and you will surely have problems with dates being sorted this way. Take the following example of a table which has a field called feed_date which defined as varchar. Now ordering the results by feed_date will not give the correct order like in the following example:</p><div class="wp_codebox"><table><tr id="p5089"><td class="code" id="p508code9"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&amp;</span>gt<span style="color: #000033;">;</span> <span style="color: #990099; font-weight: bold;">select</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">from</span> datetest <span style="color: #990099; font-weight: bold;">order by</span> feed_date<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+----+-------------------+------------+</span>
<span style="color: #CC0099;">|</span> id <span style="color: #CC0099;">|</span> feed_name         <span style="color: #CC0099;">|</span> feed_date  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+----+-------------------+------------+</span>
<span style="color: #CC0099;">|</span>  <span style="color: #008080;">1</span> <span style="color: #CC0099;">|</span> VTs Tech Blog     <span style="color: #CC0099;">|</span> <span style="color: #008080;">1</span><span style="color: #CC0099;">-</span><span style="color: #008080;">23</span><span style="color: #CC0099;">-</span><span style="color: #008080;">2008</span>  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>  <span style="color: #008080;">2</span> <span style="color: #CC0099;">|</span> vinuthomas.com    <span style="color: #CC0099;">|</span> <span style="color: #008080;">12</span><span style="color: #CC0099;">-</span><span style="color: #008080;">23</span><span style="color: #CC0099;">-</span><span style="color: #008080;">2006</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>  <span style="color: #008080;">3</span> <span style="color: #CC0099;">|</span> sitesandsounds.<span style="color: #990099; font-weight: bold;">in</span> <span style="color: #CC0099;">|</span> <span style="color: #008080;">3</span><span style="color: #CC0099;">-</span><span style="color: #008080;">12</span><span style="color: #CC0099;">-</span><span style="color: #008080;">2008</span>  <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+----+-------------------+------------+</span>
<span style="color: #008080;">3</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></td></tr></table></div><p>Hmmm&#8230; 2006 coming in between 2008 doesn&#8217;t seem right does it? The only way to get MySQL to sort this result properly will be if we can get MySQL to understand this data as a date field. To to this, we can use the mysql function <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date">STR_TO_DATE</a>. This function allows us to convert a string to date and allow us to specify in which format the date is present.</p><p>So to convert the current date format in the feed_date column which is in the mm-dd-yyyy format, we&#8217;ll have to use this syntax: STR_TO_DATE(feed_date, &#8216;%m-%d-%Y&#8217;). Now we can use this converted data to sort on:</p><div class="wp_codebox"><table><tr id="p50810"><td class="code" id="p508code10"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&amp;</span>gt<span style="color: #000033;">;</span> <span style="color: #990099; font-weight: bold;">SELECT</span> id<span style="color: #000033;">,</span> feed_name<span style="color: #000033;">,</span> feed_date <span style="color: #000033;">,</span>
 <span style="color: #000099;">STR_TO_DATE</span><span style="color: #FF00FF;">&#40;</span> feed_date<span style="color: #000033;">,</span> <span style="color: #008000;">'<span style="color: #008080; font-weight: bold;">%</span>m-<span style="color: #008080; font-weight: bold;">%</span>d-<span style="color: #008080; font-weight: bold;">%</span>Y'</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> date_for_sort
 <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #008000;">`datetest`</span> <span style="color: #990099; font-weight: bold;">ORDER BY</span> date_for_sort<span style="color: #000033;">;</span>
<span style="color: #CC0099;">+----+-------------------+-------------+--------------+</span>
<span style="color: #CC0099;">|</span> id   <span style="color: #CC0099;">|</span> feed_name        <span style="color: #CC0099;">|</span> feed_date  <span style="color: #CC0099;">|</span> date_for_sort<span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+----+--------------------+------------+--------------+</span>
<span style="color: #CC0099;">|</span>  <span style="color: #008080;">2</span>   <span style="color: #CC0099;">|</span> vinuthomas.com   <span style="color: #CC0099;">|</span> <span style="color: #008080;">12</span><span style="color: #CC0099;">-</span><span style="color: #008080;">23</span><span style="color: #CC0099;">-</span><span style="color: #008080;">2006</span> <span style="color: #CC0099;">|</span> <span style="color: #008080;">2006</span><span style="color: #CC0099;">-</span><span style="color: #008080;">12</span><span style="color: #CC0099;">-</span><span style="color: #008080;">23</span>   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>  <span style="color: #008080;">1</span>   <span style="color: #CC0099;">|</span> VTs Tech Blog    <span style="color: #CC0099;">|</span> <span style="color: #008080;">1</span><span style="color: #CC0099;">-</span><span style="color: #008080;">23</span><span style="color: #CC0099;">-</span><span style="color: #008080;">2008</span>  <span style="color: #CC0099;">|</span> <span style="color: #008080;">2008</span><span style="color: #CC0099;">-</span><span style="color: #008080;">01</span><span style="color: #CC0099;">-</span><span style="color: #008080;">23</span>   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span>  <span style="color: #008080;">3</span>   <span style="color: #CC0099;">|</span> sitesandsounds.<span style="color: #990099; font-weight: bold;">in</span><span style="color: #CC0099;">|</span> <span style="color: #008080;">3</span><span style="color: #CC0099;">-</span><span style="color: #008080;">12</span><span style="color: #CC0099;">-</span><span style="color: #008080;">2008</span>  <span style="color: #CC0099;">|</span> <span style="color: #008080;">2008</span><span style="color: #CC0099;">-</span><span style="color: #008080;">03</span><span style="color: #CC0099;">-</span><span style="color: #008080;">12</span>   <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+----+--------------------+------------+--------------+</span>
<span style="color: #008080;">3</span> rows <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></td></tr></table></div><p>Disclaimer: I know that doing this is going a round about way to getting this done, this is just a tip to help out when we have a  problem like this and can&#8217;t really change the database field declaration and you have tons of data in the field which doesn&#8217;t confirm to the MySQL date format in a varchar field.</p><p>Link: <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date">MySQL Manual on STR_TO_DATE</a></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2008/06/02/mysql-tip-ordering-by-date-stored-in-a-varchar-field/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>Why your database says paging sucks!</title><link>http://blogs.vinuthomas.com/2008/03/29/leos-why-your-database-says-paging-sucks/</link> <comments>http://blogs.vinuthomas.com/2008/03/29/leos-why-your-database-says-paging-sucks/#comments</comments> <pubDate>Sat, 29 Mar 2008 14:57:21 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2008/03/29/leos-why-your-database-says-paging-sucks/</guid> <description><![CDATA[Stumbled across this interesting article at Leo Büttiker&#8217;s blog which tells why pagination on a web app is a database killer: On the view of your database the worst thing you can do in your web app is paging. Paging is horrible in the view of performance. To explain let me take a little example: [...]]]></description> <content:encoded><![CDATA[<p>Stumbled across this interesting article at Leo Büttiker&#8217;s blog which tells why pagination on a web app is a database killer:</p><blockquote><p>On the view of your database the worst thing you can do in your web app is paging. Paging is horrible in the view of performance. To explain let me take a little example:</p><p>SELECT SQL_CALC_FOUND_ROWS gb.*,<br /> u.username,<br /> u.uid,<br /> u.geschlecht,<br /> u.mitfoto,<br /> [... some more fields...]<br /> FROM member_gold_guestbook gb<br /> LEFT JOIN users u ON u.uid=gb.uid_from<br /> [... some more left joins...]<br /> WHERE gb.uid_to=&#8217;22152&#8242;<br /> AND visible=&#8217;1&#8242;<br /> LIMIT 0,10;</p><p>That&#8217;s not that bad at all, but when you go to page 300 your database server will hat you for this. The database server has not only to calculate the 10 items you want to show but also all 3000 previous items.</p><p>Sure you may argue nobody will ever go to page 300. Somebody will not, but &#8220;googlebot&#8221; and his evil brothers will. And the bad thing is that you can, as long as you need paging, nothing do against it. There are just a few tricks that may reduce your server load a bit.</p></blockquote><p>Read the whole article at: <a href="http://leo.freeflux.net/blog/archiv/why-paging-sucks.html">@leo&#8217;s :: Why your database says paging sucks!</a></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2008/03/29/leos-why-your-database-says-paging-sucks/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ubuntu (Fiesty Fawn) on a HP nx6325 laptop</title><link>http://blogs.vinuthomas.com/2007/05/30/ubuntu-fiesty-fawn-on-a-hp-nx6325-laptop/</link> <comments>http://blogs.vinuthomas.com/2007/05/30/ubuntu-fiesty-fawn-on-a-hp-nx6325-laptop/#comments</comments> <pubDate>Wed, 30 May 2007 10:22:16 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[PHP]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/05/30/ubuntu-fiesty-fawn-on-a-hp-nx6325-laptop/</guid> <description><![CDATA[Last week I&#8217;d finally decided to move off from Windows on my work laptop. After the default installation off the 64 bit CD, here were some of the problems I found: The default Wireless drivers didn&#8217;t seem to work at all. The 64 bit version of the OS seemed to lack some of the softwares [...]]]></description> <content:encoded><![CDATA[<p>Last week I&#8217;d finally decided to move off from Windows on my work laptop. After the default installation off the 64 bit  CD, here were some of the problems I found:</p><ul><li>The default Wireless drivers didn&#8217;t seem to work at all.</li><li>The 64 bit version of the OS seemed to lack some of the softwares like Flash player and w32codecs.</li><li>The external monitor/projecter didn&#8217;t work off the default installation.</li><li>My development stack of LAMP had to be installed manually.</li><li>Very basic multimedia support.</li></ul><p>I reinstalled the laptop with the 32-bit OS instead, to get a hold of the missing software on the 64 bit version. The wireless was still down. A quick google search landed me at the following blog, which had a great step-by-step instruction on how to get ndiswrapper and the windows version of the Broadcom wireless driver to work on the laptop.<br /> Instruction for installing the Broadcom drivers through ndiswrapper: <a href="http://vale.homelinux.net/wordpress/?p=144">http://vale.homelinux.net/wordpress/?p=144</a></p><p>To get the external display working, I followed the instructions over at Ubuntu&#8217;s community help site: <a href="https://help.ubuntu.com/community/BinaryDriverHowto/ATI">https://help.ubuntu.com/community/BinaryDriverHowto/ATI</a>.<br /> The default open source drivers didn&#8217;t have support for  TV-out. The instructions I followed were quite simple:</p><p><em>Install linux-restricted-modules and restricted-manager provied in the restricted repositories: </em><br /> <code>sudo apt-get update<br /> sudo apt-get install linux-restricted-modules-generic restricted-manager</code><br /> <em>Open the restricted drivers manager included in 7.04 &#8220;System -&gt; Administration -&gt; Restricted Drivers Manager&#8221; and select &#8220;ATI accelerated graphics driver&#8221;. This will hopefully enable fglrx in a painless way. If not, follow the instructions for Edgy.</em></p><p>Apart from the instructions above you&#8217;ll also have to install fglrx-control. At the shell prompt type in:</p><p><code>sudo apt-get install fglrx-control</code></p><p>After this you can access the ATI control panel by issuing the following command at the prompt.</p><p><code>sudo fireglcontrol</code></p><p>These took care of my basic necessities. Had my network and basic software installed. Being a LAMP developer, I had to get LAMP installed on the laptop. Here&#8217;s how to get it done:</p><p><code>apt-get install apache2<br /> apt-get install php5 libapache2-mod-php5<br /> apt-get install php5-cli php5-dev<br /> apt-get install php-pear</code></p><p>The first two gets apache2, and the php modules installed. The next two get the php command line, php dev libraries and pear installed on the system. Next let&#8217;s get MySQL up and running:</p><p><code>apt-get install mysql-server mysql-client </code></p><p>This installs MySQL server and the client setup. To setup the mysql libraries for PHP5, run the following:</p><p><code>apt-get install php5-mysql</code></p><p>Linux still lacks an IDE for LAMP development, so while I search the net for a suitable candidate, I guess gedit or Quanta will work fine for coding. <img src='http://blogcdn.vinuthomas.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> One of the candidates in the open source area for this task is <a href="http://www.eclipse.org/pdt/">PDT</a>, I&#8217;m yet to evaluate it.</p><p>To get all the other multimedia goodies installed on my system, I used <a href="http://ubuntuforums.org/showthread.php?t=181248">BUMPS</a>.</p><p>If your company has some nagging legacy web applications which refuse to work on anything other than IE, you can also install IE on Ubuntu using ies4linux. Here&#8217;s a link which shows you how do go about this:</p><p><a href="http://www.psychocats.net/ubuntu/ies4linux">http://www.psychocats.net/ubuntu/ies4linux</a></p><p>Be warned that having IE on your system legally requires that you have a valid license for Windows.</p><p>If you&#8217;re pulling out your hair wondering why the hell will some one install IE on Linux, it&#8217;s just that some nasty web-application developers  make cross-browser compatible apps that work on any browser as long as it is IE!</p><p><img src="http://blogs.vinuthomas.com/wp-images/advertisement.png" /><br /> A large number of <a href="http://www.cableunplugged.com/Wireless-Broadband.html">wireless broadband</a> services like <a href="http://www.cableunplugged.com/Sprint-Wireless.html">sprint wireless</a> and <a href="http://www.cableunplugged.com/Verizon-Wireless.html">verizon wireless</a> have sprouted with increasing trend of wireless. Also, with the advent of <a href="http://www.srh.noaa.gov/cte.htm">wireless internet hotspots</a>, <a href="http://www.nysl.nysed.gov/wireless.htm">wireless internet coverage</a> has expanded.</p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/05/30/ubuntu-fiesty-fawn-on-a-hp-nx6325-laptop/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Amazon AWS S3 MySQL Storage Engine</title><link>http://blogs.vinuthomas.com/2007/04/26/amazon-aws-s3-mysql-storage-engine/</link> <comments>http://blogs.vinuthomas.com/2007/04/26/amazon-aws-s3-mysql-storage-engine/#comments</comments> <pubDate>Thu, 26 Apr 2007 14:47:22 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[amazon]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[s3]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/04/26/amazon-aws-s3-mysql-storage-engine/</guid> <description><![CDATA[Amazon&#8217;s S3 service seems to be getting into everything &#8216;online&#8217; these days. Here&#8217;s an announcement by Mark Atwood of a S3 storage engine for MySQL 5. It allows one to view and manipulate Amazon&#8217;s S3 storage service as tables and items by MySQL. You can keep your blobs or large varchars or truely huge datasets [...]]]></description> <content:encoded><![CDATA[<p>Amazon&#8217;s S3 service seems to be getting into everything &#8216;online&#8217; these days.  Here&#8217;s an announcement by Mark Atwood of a S3 storage engine for MySQL 5.</p><p><em>It allows one to view and manipulate Amazon&#8217;s S3 storage service as<br /> tables and items by MySQL.  You can keep your blobs or large varchars<br /> or truely huge datasets in S3, and then join the tables against your<br /> local ones.</em></p><p>Announcement: <a href="http://lists.mysql.com/internals/34560">MySQL Lists: internals: Storage engine for Amazon S3</a><br /> Mark&#8217;s project page: <a href="http://fallenpegasus.com/code/">http://fallenpegasus.com/code/</a></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/04/26/amazon-aws-s3-mysql-storage-engine/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Insert and Update in one query</title><link>http://blogs.vinuthomas.com/2007/03/30/insert-and-update-in-one-query/</link> <comments>http://blogs.vinuthomas.com/2007/03/30/insert-and-update-in-one-query/#comments</comments> <pubDate>Fri, 30 Mar 2007 14:31:53 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[insert]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[query]]></category> <category><![CDATA[update]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/03/30/insert-and-update-in-one-query/</guid> <description><![CDATA[Here&#8217;s a quick tip in MySQL. Let&#8217;s say you have a table called browsercount like the one below: id browser count 1 Internet Explorer 1 2 Opera 2 Let&#8217;s say you have a web-analytic application which has to add a browser into the table if it doesn&#8217;t exist, but update the count for the browser [...]]]></description> <content:encoded><![CDATA[<p>Here&#8217;s a quick tip in MySQL. Let&#8217;s say you have a table called browsercount like the one below:</p><table style="text-align: left" border="1" cellpadding="2" cellspacing="2" height="64" width="496"><tr><td style="width: 33%; font-weight: bold">id</td><td style="width: 33%; font-weight: bold">browser</td><td style="font-weight: bold">count</td></tr><tr><td>1</td><td>Internet Explorer</td><td>1</td></tr><tr><td style="width: 184px">2</td><td style="width: 436px">Opera</td><td>2</td></tr></table><p>Let&#8217;s say you have a web-analytic application which has to add a browser into the table if it doesn&#8217;t exist, but update the count for the browser if the entry already exists. How do you go about that?</p><p>The usual way would be to first query the table to see if the entry exists, then fire an insert statement or an update statement based on the results.</p><p>Here&#8217;s how to perform the same action in one SQL statement:</p><p><code>INSERT INTO browsercount (browser,count) VALUES ('Firefox',1) ON DUPLICATE KEY UPDATE count=count+1;</code></p><p>This will work if the id field in the table above is declared as UNIQUE or is a Primary Key.</p><p>The query basically tells mysql to insert the data into the database, but if a duplicate key is found, increment the count field by 1. It&#8217;s much faster than firing up 2 sql queries from your PHP script <img src='http://blogcdn.vinuthomas.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/03/30/insert-and-update-in-one-query/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Performance Tuning Best Practices for MySQL (Video)</title><link>http://blogs.vinuthomas.com/2007/02/21/performance-tuning-best-practices-for-mysql-video/</link> <comments>http://blogs.vinuthomas.com/2007/02/21/performance-tuning-best-practices-for-mysql-video/#comments</comments> <pubDate>Wed, 21 Feb 2007 03:15:50 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[performance]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/02/21/performance-tuning-best-practices-for-mysql-video/</guid> <description><![CDATA[This video is from one of Google&#8217;s Techtalk sessions by Jay Pipes ABSTRACT Learn where to best focus your attention when tuning the performance of your applications and database servers, and how to effectively find the &#8220;low hanging fruit&#8221; on the tree of bottlenecks. It&#8217;s not rocket science, but with a bit of acquired skill [...]]]></description> <content:encoded><![CDATA[<p>This video is from one of Google&#8217;s Techtalk sessions by Jay Pipes<br /> <embed id="VideoPlayback" style="width:400px;height:326px" allowFullScreen="true" flashvars="fs=true" src="http://video.google.com/googleplayer.swf?docid=2524524540025172110&#038;hl=en" type="application/x-shockwave-flash"> </embed><br /> ABSTRACT Learn where to best focus your attention when tuning the performance of your applications and database servers, and how to effectively find the &#8220;low hanging fruit&#8221; on the tree of bottlenecks. It&#8217;s not rocket science, but with a bit of acquired skill and experience, and of course good habits, you too can do this magic!</p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/02/21/performance-tuning-best-practices-for-mysql-video/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Debugging sleeping connections with MySQL</title><link>http://blogs.vinuthomas.com/2007/02/19/debugging-sleeping-connections-with-mysql/</link> <comments>http://blogs.vinuthomas.com/2007/02/19/debugging-sleeping-connections-with-mysql/#comments</comments> <pubDate>Mon, 19 Feb 2007 08:02:04 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/02/19/debugging-sleeping-connections-with-mysql/</guid> <description><![CDATA[I&#8217;ve had to to look at this situation quite a few times on live servers, where the number of MySQL connections seemed to exceed the max limit of the server and PHP used to throw &#8220;Too many connections&#8221; error when a MySQL query was run. When we looked at the MySQL process list, it showed [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve had to to look at this situation quite a few times on live servers, where the number of MySQL connections seemed to exceed the max limit of the server and PHP used to throw &#8220;Too many connections&#8221; error when a MySQL query was run. When we looked at the MySQL process list, it showed quite a few MySQL connections in the Sleep state. Here&#8217;s an article from MySQL Performance Blog on debugging such connections.</p><blockquote><p>I see if frequently with web applications and it is often indication of trouble. Not only it means you may run out of MySQL connections quicker than you expected but it also frequently indicates serious problems in the application. If you do not use persistent connections and you have connection in Sleep stage for 600 seconds what could it be ? It may mean some of your pages take that long to generate (or might be the code simply gets into the tight loop and page never gets generated) it also could mean some of external Web Services are slow or not available and you’re not dealing with timeouts properly. Or may be you have several connections to MySQL server and right now running query which takes that long ? In any case it is something frequently worth looking at.</p></blockquote><p>Link: <a href="http://www.mysqlperformanceblog.com/2007/02/08/debugging-sleeping-connections-with-mysql/">MySQL Performance Blog » Debugging sleeping connections with MySQL</a></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/02/19/debugging-sleeping-connections-with-mysql/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>MySQL Activity Report</title><link>http://blogs.vinuthomas.com/2007/01/29/mysql-activity-report/</link> <comments>http://blogs.vinuthomas.com/2007/01/29/mysql-activity-report/#comments</comments> <pubDate>Mon, 29 Jan 2007 08:01:58 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[report]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/01/29/mysql-activity-report/</guid> <description><![CDATA[Here&#8217;s a cool utility for MySQL administrators which allows you to track the performance of your servers and also gives you performance enhancement tips. You can see a sample report from this tool over at: http://gert.sos.be/demo/mysqlar/ The MySQL Activity Report package is a tool to help MySQL database administrators to collect several database parameters and [...]]]></description> <content:encoded><![CDATA[<p>Here&#8217;s  a cool utility for MySQL administrators which allows you to track the performance of your servers and also gives you performance enhancement tips. You can see a sample report from this tool over at: <a href="http://gert.sos.be/demo/mysqlar/">http://gert.sos.be/demo/mysqlar/</a><br /> The MySQL Activity Report package is a tool to help MySQL database administrators to collect several database parameters and variables. These collected values can be used for server monitoring or performance tuning purposes.</p><p>Link: <a href="http://gert.sos.be/en/">MySQL Activity Report</a></p><p>For Installation Instructions, head over to: <a href="http://www.linuxforums.org/forum/servers/72890-how-mysql-activity-report.html">http://www.linuxforums.org/forum/servers/72890-how-mysql-activity-report.html</a></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/01/29/mysql-activity-report/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Innodb locking and Foreign Keys</title><link>http://blogs.vinuthomas.com/2007/01/17/innodb-locking-and-foreign-keys/</link> <comments>http://blogs.vinuthomas.com/2007/01/17/innodb-locking-and-foreign-keys/#comments</comments> <pubDate>Wed, 17 Jan 2007 15:00:35 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[mysql]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2007/01/17/innodb-locking-and-foreign-keys/</guid> <description><![CDATA[Here&#8217;s a MySQL tip from the MySQL Performance Blog which deals with possible lock situations while using InnoDB and foreign keys. Today I was working with application which uses Innodb and foreign keys and got into locking problems possibly due to foreign keys, so I did a little investigation on that matter. Peter Zaitsev goes [...]]]></description> <content:encoded><![CDATA[<p>Here&#8217;s a MySQL tip from the <a href="http://www.mysqlperformanceblog.com">MySQL Performance Blog</a> which deals with possible lock situations while using InnoDB and foreign keys.</p><p><em>Today I was working with application which uses Innodb and foreign keys and got into locking problems possibly due to foreign keys, so I did a little investigation on that matter.</em></p><p>Peter Zaitsev goes on to outline an example of when this could happen and warns developers to look at locking overheads while implementing foreign keys in Innodb</p><p>Link: <a href="http://www.mysqlperformanceblog.com/2006/12/12/innodb-locking-and-foreign-keys/">MySQL Performance Blog » Innodb locking and Foreign Keys</a></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2007/01/17/innodb-locking-and-foreign-keys/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Modifying your MySQL databases to be UTF-8 compliant</title><link>http://blogs.vinuthomas.com/2006/12/22/modifying-your-mysql-databases-to-be-utf-8-compliant/</link> <comments>http://blogs.vinuthomas.com/2006/12/22/modifying-your-mysql-databases-to-be-utf-8-compliant/#comments</comments> <pubDate>Fri, 22 Dec 2006 10:22:48 +0000</pubDate> <dc:creator>vinu</dc:creator> <category><![CDATA[Databases]]></category><guid isPermaLink="false">http://blogs.vinuthomas.com/2006/12/22/modifying-your-mysql-databases-to-be-utf-8-compliant/</guid> <description><![CDATA[Most of us have had problems with UTF-8 problems in PHP and MySQL. Here’s how to modify your database and table to be UTF-8 compliant. Most of the time we do set the character set to utf8 but forget to set the collation set to utf8. Use the following MySQL statements to convert your database [...]]]></description> <content:encoded><![CDATA[<p>Most of us have had problems with UTF-8 problems in PHP and MySQL. Here’s how to modify your database and table to be UTF-8 compliant. Most of the time we do set the character set to utf8 but forget to set the collation set to utf8.</p><p>Use the following MySQL statements to convert your database and tables:</p><p><code>ALTER DATABASE mydatabase<br /> CHARACTER SET utf8<br /> DEFAULT CHARACTER SET utf8<br /> COLLATE utf8_general_ci<br /> DEFAULT COLLATE utf8_general_ci	;</code><br /> <code><br /> ALTER TABLE mytable<br /> DEFAULT CHARACTER SET utf8<br /> COLLATE utf8_general_ci	;</code></p> ]]></content:encoded> <wfw:commentRss>http://blogs.vinuthomas.com/2006/12/22/modifying-your-mysql-databases-to-be-utf-8-compliant/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 2/20 queries in 0.026 seconds using disk
Content Delivery Network via blogcdn.vinuthomas.com

Served from: blogs.vinuthomas.com @ 2010-09-03 19:49:47 -->