<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Saviour&#039;s Blog</title>
	<atom:link href="http://saviourc.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://saviourc.wordpress.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Aug 2011 22:43:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='saviourc.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Saviour&#039;s Blog</title>
		<link>http://saviourc.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://saviourc.wordpress.com/osd.xml" title="Saviour&#039;s Blog" />
	<atom:link rel='hub' href='http://saviourc.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Website Control Login with jQuery</title>
		<link>http://saviourc.wordpress.com/2009/10/01/website-control-login-with-jquery/</link>
		<comments>http://saviourc.wordpress.com/2009/10/01/website-control-login-with-jquery/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 20:18:50 +0000</pubDate>
		<dc:creator>saviourc</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://saviourc.wordpress.com/?p=71</guid>
		<description><![CDATA[Having multiple websites with different environment can be a pain to use or switch between them. This gave me an idea to create a control panel automated in jQuery. This is my real first go with  jQuery, as all other were snippets which end up in the bin. I already had a simple HTML page [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=71&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having multiple websites with different environment can be a pain to use or switch between them. This gave me an idea to create a control panel automated in jQuery. This is my real first go with  jQuery, as all other were snippets which end up in the bin.</p>
<p>I already had a simple HTML page with buttons which posted login information to the login page so I could login with a single click. This page was made simple and addition websites required a new form with new hidden input fields and a button. Repeat this for each site added was becoming tedious and that is were the idea lit up.</p>
<p>I wanted a simple array which contains all the websites name, environment, username and password located nicely in one place. This way it&#8217;s easier to manta in the website being located in a nicely tight place. With this in mind, the following was coded.</p>
<p><pre class="brush: jscript;">
var operators = [
    { name: &quot;Site1&quot;, env: &quot;Env1&quot;, username: &quot;testuser1&quot;, password: &quot;testpass1&quot; },
    { name: &quot;Site2&quot;, env: &quot;Env2&quot;, username: &quot;testuser2&quot;, password: &quot;testpass2&quot; },
    { name: &quot;Site3&quot;, env: &quot;Env3&quot;, username: &quot;testuser3&quot;, password: &quot;testpass3&quot; },
];
</pre></p>
<p>With this set, I can add or remove entries at will without any real code involved.</p>
<p><span id="more-71"></span></p>
<p>Now it&#8217;s time for the JavaScript magic to happen. Forms all work the same, thus having a target location were to post and parameters to pass to the website. I needed a form with 2 parameters, a username and a password so it does login automatically. Yes I&#8217;m very lazy, but when managing websites all with their flavored username and password, it&#8217;s hard to remember them all. Being a developer there&#8217;s no risk in exposing passwords as the aim of this page is to be used on my computer to connect to testing servers were I&#8217;m logging in and out every minute.</p>
<p>jQuery came handy when building dynamic elements according to the entries in the array specified above. The code is simple, all it does is to loop through all website entries, creates a button for each and attaches a click event. The click event handles all the parameter settings, in my case, the username and password. The parameters are attached to the form dynamically and an action is set to the form according to the selected button. After all is set, the form is submitted with all parameters necessary.</p>
<p><pre class="brush: jscript;">
$(document).ready(function() {
    for (var index in operators) {
        var operator = operators[index];
        $(&quot;&amp;lt;input type='button'&amp;gt;&quot;) // create a button
            .val(operator.env + &quot; &quot; + operator.name + &quot; Site&quot;) // set button text
            .appendTo(&quot;#content&quot;) // append to main div
            .click(function() { // click event
                var operatorClicked = operators[$(&quot;:button&quot;).index(this)]; // get operator with the index of the clicked button
                $(&quot;form&quot;)
                    .append($(&quot;&amp;lt;input&amp;gt;&quot;).attr(&quot;type&quot;, &quot;hidden&quot;).attr(&quot;name&quot;, &quot;username&quot;).val(operatorClicked.username)) // create form username
                    .append($(&quot;&amp;lt;input&amp;gt;&quot;).attr(&quot;type&quot;, &quot;hidden&quot;).attr(&quot;name&quot;, &quot;password&quot;).val(operatorClicked.password)) // create form password
                    .attr(&quot;action&quot;, &quot;http://&quot; + operatorClicked.name.toLowerCase() + &quot;.&quot; + operatorClicked.env.toLowerCase() + &quot;.&amp;lt;&amp;lt;xwebsitex&amp;gt;&amp;gt;.com&quot;) // set url
                    .submit(); // submit form
            });
    }
});
</pre></p>
<p>The body only contained a form tag and a div were I could add the buttons. The div isn&#8217;t really necessary as i could have just added the buttons directly to the body.</p>
<p>This could be improved a lot by creating a more complex definition of the website object defined in the array operators. Some style should be added as well to even out all buttons on screen. For now this is what I needed and it works wonders.</p>
<p>If you have any suggestions on how to improve the code let me know as this is my first push at jQuery.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saviourc.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saviourc.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saviourc.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saviourc.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saviourc.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saviourc.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saviourc.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saviourc.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=71&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saviourc.wordpress.com/2009/10/01/website-control-login-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e4e8a6b851659b0e957e8679f47f82e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saviourc</media:title>
		</media:content>
	</item>
		<item>
		<title>SHA1 Speed Differences [PHP vs MySQL] – Part 2</title>
		<link>http://saviourc.wordpress.com/2009/09/26/sha1-speed-differences-php-vs-mysql-part-2/</link>
		<comments>http://saviourc.wordpress.com/2009/09/26/sha1-speed-differences-php-vs-mysql-part-2/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 22:37:00 +0000</pubDate>
		<dc:creator>saviourc</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SHA1]]></category>

		<guid isPermaLink="false">http://saviourc.wordpress.com/?p=57</guid>
		<description><![CDATA[Back again for the second part of SHA1 Speed Differences. Who will win this battle between PHP vs MySQL? This post is a continuation of SHA1 Speed Differences [PHP vs MySQL] – Part 1 directly replying to the post MD5/SHA1 Encryption in PHP vs. MySQL. As discussed in part 1, using an index on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=57&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Back again for the second part of SHA1 Speed Differences. Who will win this battle between PHP vs MySQL? This post is a continuation of <a href="http://saviourc.wordpress.com/2009/09/24/sha1-speed-differences-php-vs-mysql-part-1/" target="_blank">SHA1 Speed Differences [PHP vs MySQL] – Part 1</a> directly replying to the post <a href="http://fwebde.com/php/encryption-php-vs-mysql/" target="_blank">MD5/SHA1 Encryption in PHP vs. MySQL</a>.</p>
<p>As discussed in part 1, using an index on the digest field brings us to a reasonable results. This post will be based around differences in speed performance between PHP vs MySQL. It is based on a lot of testing but I won&#8217;t annoy you with a lot of numbers.</p>
<p>First thing I noticed was, that if I increased the number of records from 500 to 1000 and even to 2000, the increase in query time was becoming drastically large. One problem was due to the index, which I&#8217;ve explained in part 1 but the difference in PHP vs MySQL was becoming evident. The table had no index for both queries which lead  me to think that MySQL version had something wrong. To cut it short, when MySQL manages to get the result spot on with the index or few records (like 10-100), the speed difference between PHP vs MySQL is negligible, but when the amount of records increase, MySQL SHA1 was really slowing down. The results I kept getting were as follows (only select queries done):</p>
<table border="0">
<thead>
<tr>
<td>Rows</td>
<td>PHP</td>
<td>MySQL</td>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">500</td>
<td style="text-align:right;">3.947ms</td>
<td style="text-align:right;">5.273ms</td>
</tr>
<tr>
<td style="text-align:right;">1000</td>
<td style="text-align:right;">4.884ms</td>
<td style="text-align:right;">9.603ms</td>
</tr>
<tr>
<td style="text-align:right;">2000</td>
<td style="text-align:right;">5.856ms</td>
<td style="text-align:right;">15.507ms</td>
</tr>
</tbody>
</table>
<p><span id="more-57"></span>After I&#8217;ve identified that SHA1 had a problem dealing with thousands of records, I had to identify why it was slow. My first thought was that it was computing SHA1 for each record, seeing that the results above show an increase in execution time by nearly 3 times as much as PHP&#8217;s version. Considering PHP query was only doing a simple string compare for every record traversed while MySQL was doing an SHA1 function plus a string compare for each record thus slowing much more than PHP.</p>
<p><span style="font-size:large;"><strong>Deterministic or Not?</strong></span></p>
<p>I didn&#8217;t want to accept this as SHA1 function is <a href="http://en.wikipedia.org/wiki/Deterministic_algorithm" target="_blank">deterministic</a> were if you give the same string to hash, it will always give you the same digest in return. Usually deterministic function like this, are only executed once as the result will be the same for all further checks. The results show differently and it seems it is really executing the SHA1 function for each record. The question was, how do we identify if it is really deterministic or not?</p>
<p>At first I thought I&#8217;d do a simple SHA1 query (ex. &#8216;SELECT SHA1(&#8216;digist_string&#8217;);&#8217;) before the actual queries which would make it much more similar to the PHP version. This would be identical to PHP version but involved an extra query. A second idea had been put through one of my colleagues which was actually what I was searching for. A sub-select was the answer. In DB terms and optimizations, a sub-select is ran before and the return is used to continue the traversal bringing us to only a string comparison. So ready for another test batch with our ideal way of querying MySQL to identify if SHA1 is being used as deterministic or not was on its way.</p>
<p>The change in code was simple. MySQL query was changed from &#8221;SELECT identity FROM test_table WHERE digest = sha1(?)&#8221; to &#8220;SELECT identity FROM test_table WHERE digest = (SELECT sha1(?))&#8221;. I know you may think this is babish and maybe not necessary but the results proof otherwise as the MySQL optimizer works different than our elementary reasoning. The test that follow are based on the basic table structure and a non indexed digest field. Only select queries were recorded.</p>
<table border="0">
<thead>
<tr>
<td>Rows</td>
<td>PHP</td>
<td>MySQL</td>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">500</td>
<td style="text-align:right;">3.947ms</td>
<td style="text-align:right;">4.066ms</td>
</tr>
<tr>
<td style="text-align:right;">1000</td>
<td style="text-align:right;">4.710ms</td>
<td style="text-align:right;">4.917ms</td>
</tr>
<tr>
<td style="text-align:right;">2000</td>
<td style="text-align:right;">5.919ms</td>
<td style="text-align:right;">5.893ms</td>
</tr>
</tbody>
</table>
<p>As you can see from the results, MySQL is actually considering SHA1 as non-deterministic when traversing records. I&#8217;ve tried to research more about this and checked MySQL source code for this to no avail. Maybe I haven&#8217;t searched enough but till now this is my conclusion on this subject.</p>
<p>If you are using cryptographic functions in MySQL and the field queried is not indexed, please make sure to either change the code to a sub-query or change the structure.</p>
<p><span style="font-size:large;"><strong>Conclusion &#8211; PHP or MySQL?</strong></span></p>
<p>Coming to the original post idea, PHP vs MySQL SHA1 functions really don&#8217;t differ in speed. My suggestion is to use what you&#8217;re mostly comfortably using and least troublesome for you. Happy programming.</p>
<p>Any comments or advice is appreciated.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saviourc.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saviourc.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saviourc.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saviourc.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saviourc.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saviourc.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saviourc.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saviourc.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=57&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saviourc.wordpress.com/2009/09/26/sha1-speed-differences-php-vs-mysql-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e4e8a6b851659b0e957e8679f47f82e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saviourc</media:title>
		</media:content>
	</item>
		<item>
		<title>SHA1 Speed Differences [PHP vs MySQL] &#8211; Part 1</title>
		<link>http://saviourc.wordpress.com/2009/09/24/sha1-speed-differences-php-vs-mysql-part-1/</link>
		<comments>http://saviourc.wordpress.com/2009/09/24/sha1-speed-differences-php-vs-mysql-part-1/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 19:48:52 +0000</pubDate>
		<dc:creator>saviourc</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SHA1]]></category>

		<guid isPermaLink="false">http://saviourc.wordpress.com/?p=32</guid>
		<description><![CDATA[Reading my favorite blog, I&#8217;ve encountered a rather interesting article discussing the speed difference between PHP and MySQL in SHA1 algorithms. The results obtained were suspicious to me. Usually in database terms, reads are faster then inserts, but in this case it was the opposite. Being the hard headed I am, I had to find out what was wrong with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=32&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Reading my favorite <a href="http://karlagius.com" target="_blank">blog</a>, I&#8217;ve encountered a rather interesting <a href="http://fwebde.com/php/encryption-php-vs-mysql/" target="_blank">article</a> discussing the speed difference between PHP and MySQL in SHA1 algorithms. The results obtained were suspicious to me. Usually in database terms, <strong>reads are faster then inserts</strong>, but in this case it was the opposite.</p>
<p>Being the hard headed I am, I had to find out what was wrong with the tests conducted in that article. The poster kindly provided the source which was really dandy as I could execute the same tests as the poster did. After several head bangs trying to setup PHP to work flawless on my pc, I managed to analyse the tests.</p>
<p>At first glance, everything looked really well done and flawless. Tests were godly written and everything was up to standard. After considerable time contemplating and a beer, I came to the conclusion that the problem lies elsewhere. The tests were simple enough that it was very easy to understand and even test. One query had a fixed string and the other one had an SHA1 function call from MySQL, exactly as the test intended.</p>
<p>The thought that was haunting me was that even the normal PHP method, (ie. the string comparison) <strong>reading was slower than the insert</strong>. Looking at this problem alone and excluding PHP vs MySQL performance led me to the problems. Yes that&#8217;s right, there is more than one problem. It&#8217;s not how the tests are written but it&#8217;s more how databases work internally which should be taken into consideration once working with databases.<span id="more-32"></span></p>
<p><span style="font-size:large;"><strong>Database Search Explained</strong></span></p>
<p>Before explaining the problem, let&#8217;s discuss a bit on how databases normally work and how they fetch data. Let&#8217;s take the tests provided by the poster and use his table as our example reference.</p>
<pre><code>CREATE TABLE test_table (
    identity INTEGER AUTO_INCREMENT,
    digest VARCHAR(41),
    PRIMARY KEY (identity)
);</code></pre>
<p>This is the table structure and as you can see, it is simple and perfectly normal. It has two fields, a numeric primary key and a string field of length 41 to store our hashed data.</p>
<p>When the database is asked to retrieve information which have &#8216;digest&#8217; equals to &#8216;hello&#8217;, the database has to check each row if the text in &#8216;digest&#8217; field matches &#8216;hello&#8217;. If there are 500 records, the database will check 500 records one by one and at the end returns the records which have digest = &#8216;hello&#8217;. As explained before, this is how normally work and not how they should work. This method of search can become very slow on large tables as checking each and every row isn&#8217;t a very intelligent way to search. Telephone directories have indices and each page is sorted by the surname to ease your searching. Imagine going through your telephone directory searching for the surname of &#8216;Zohan John&#8221; which should be located in the last few pages. That would take ages and this also applies for databases. This also applies for databases which make use of indices and sorting to retrieve that information quicker.</p>
<p>With an index on the &#8216;digest&#8217; field one can locate information much faster instead of checking each field one by one. What happens when a database searches for information on an indexed field (the whole field is indexed and not the first letter or two)  is as follows. It will ask the index if there&#8217;s anything that matches the whole word &#8216;hello&#8217;. The index will reply with either a &#8216;match&#8217; or &#8216;no match&#8217;. If a match is returned, the location will be identified and the database can go and retrieve the information immediately without waisting any more valuable time asking each and every record if it matches. The result is usually instant which is what raised my interest in the article.</p>
<p><span style="font-size:large;"><strong>Index Search vs Normal Search</strong></span></p>
<p>After all the technicalities, it is time to see if what is said above is the culprit. The test is inserting 500 records into the table and querying the database 500 times one for each record which returns with a match. Without an index, the database has to go through all records and thus the &#8216;select&#8217; results are slower then the &#8216;insert&#8217; commands. Second beer in hand, I placed the index and the results produced were much better. The new table structure looks like this.</p>
<pre><code>CREATE TABLE test_table (
    identity INTEGER AUTO_INCREMENT,
    digest VARCHAR(41),
    PRIMARY KEY (identity),
    KEY (digest)
);</code></pre>
<p>This solved the first problem which was haunting me like my worst nightmare. <strong>Is &#8216;select&#8217; slower than &#8216;insert&#8217;?</strong></p>
<p><span style="font-size:large;"><strong>Results &#8211; Select vs Insert</strong></span></p>
<p>My average results vary from the original article but the difference can still be identified.</p>
<table border="0">
<tbody>
<tr>
<td>Records</td>
<td>Normal Select</td>
<td>Index Select</td>
<td>Insert</td>
</tr>
<tr>
<td style="text-align:right;">10</td>
<td style="text-align:right;">1.9342ms</td>
<td style="text-align:right;">1.7923ms</td>
<td style="text-align:right;">2.1394ms</td>
</tr>
<tr>
<td style="text-align:right;">500</td>
<td style="text-align:right;">2.5648ms</td>
<td style="text-align:right;">1.7885ms</td>
<td style="text-align:right;">2.2872ms</td>
</tr>
<tr>
<td style="text-align:right;">1000</td>
<td style="text-align:right;">3.1148ms</td>
<td style="text-align:right;">1.7948ms</td>
<td style="text-align:right;">2.0497ms</td>
</tr>
<tr>
<td style="text-align:right;">5000</td>
<td style="text-align:right;">3.6964ms</td>
<td style="text-align:right;">1.7961ms</td>
<td style="text-align:right;">2.2519ms</td>
</tr>
</tbody>
</table>
<p>This shows that the indexed search really does a great job when dealing with a lot of information. They&#8217;re a necessity for a database to work soundly. I am not implying one should go overboard with indices but one should know when and how to use them.</p>
<p>With this said, there&#8217;s still the performance issue between PHP vs MySQL. Could it be MySQL performs a function which basically does the same that much slower, 4 times slower? Be patient and I&#8217;ll post my finding in another post as this is already too long to read.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saviourc.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saviourc.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saviourc.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saviourc.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saviourc.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saviourc.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saviourc.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saviourc.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=32&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saviourc.wordpress.com/2009/09/24/sha1-speed-differences-php-vs-mysql-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e4e8a6b851659b0e957e8679f47f82e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saviourc</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Visualization Configuration Options</title>
		<link>http://saviourc.wordpress.com/2009/09/19/google-visualization-configuration-options/</link>
		<comments>http://saviourc.wordpress.com/2009/09/19/google-visualization-configuration-options/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 13:12:35 +0000</pubDate>
		<dc:creator>saviourc</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Chart]]></category>
		<category><![CDATA[Google Visualization]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://saviourc.wordpress.com/?p=18</guid>
		<description><![CDATA[Continuing with the previous post, I wanted to modify the default area chart a little more. While I was skimming the page containing the methods and events, I got stuck on the section &#8216;Configuration Options&#8217;. That being said, the page looks like a JavaDoc thus placing methods, properties and the sorts on the same page [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=18&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Continuing with the previous post, I wanted to modify the default area chart a little more.</p>
<p>While I was skimming the <a title="Google Visualization: Area Chart" href="http://code.google.com/apis/visualization/documentation/gallery/areachart.html" target="_blank">page</a> containing the methods and events, I got stuck on the section &#8216;Configuration Options&#8217;. That being said, the page looks like a JavaDoc thus placing methods, properties and the sorts on the same page and of similar format.</p>
<p>My first guess without reading anything I tried to set the line colors of the area chart with the following code:</p>
<p><pre class="brush: jscript;">
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.color = [ 'black', 'green' ];
</pre></p>
<p><span id="more-18"></span>How wrong was I. To my astonishment, when I refreshed the page, the chart was gone with a JavaScript error notifying me that something wrong happened. Bite me, I went to the code again and tried a different option as the JavaScript error said that it doesn&#8217;t support that property. Fine after changing a few more options I recognized that none worked as I had thought.</p>
<p>Hard as my will is, I went with a different route. &#8216;Google supports JSON as data maybe even options?&#8217; With that in mind, another object has been created and applied to the draw method as a parameter.</p>
<p><pre class="brush: jscript;">
var options = {
    colors: [ 'orange', 'green' ],
    legend: 'bottom',
    title: 'Area Chart Test'
};

chart.draw(data, options);
</pre></p>
<p>After another refresh, the chart had re-appeared again and also significantly different. It was wider due to the legend being placed below and the colors changed as well.</p>
<p>With this in mind, I can say that when you work with Google tools, JSON must be a necessity to get the tools to work.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saviourc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saviourc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saviourc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saviourc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saviourc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saviourc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saviourc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saviourc.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=18&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saviourc.wordpress.com/2009/09/19/google-visualization-configuration-options/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e4e8a6b851659b0e957e8679f47f82e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saviourc</media:title>
		</media:content>
	</item>
		<item>
		<title>Joys of Free Tools</title>
		<link>http://saviourc.wordpress.com/2009/09/19/joys-of-free-tools/</link>
		<comments>http://saviourc.wordpress.com/2009/09/19/joys-of-free-tools/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 22:47:22 +0000</pubDate>
		<dc:creator>saviourc</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Chart]]></category>
		<category><![CDATA[Google Visualization]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://saviourc.wordpress.com/?p=6</guid>
		<description><![CDATA[There we are, another day passed and as promised I&#8217;m gonna get some features jotted down. I was approached by a friend to lend a hand in his project which turns out being quite interesting. The project resulted to be simple with the end result of showing a graph of daily values. I knew about [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=6&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There we are, another day passed and as promised I&#8217;m gonna get some features jotted down.</p>
<p>I was approached by a friend to lend a hand in his project which turns out being quite interesting. The project resulted to be simple with the end result of showing a graph of daily values.</p>
<p>I knew about <a title="Google Visualization" href="http://code.google.com/apis/visualization/" target="_blank">Google visualization</a> package which consists around a gazillion of free, very useful tools. While browsing the <a title="Google Visualization Gallery" href="http://code.google.com/apis/visualization/documentation/gallery.html" target="_blank">gallery</a>, I encountered what i needed most: &#8216;<a title="Area Chart" href="http://code.google.com/apis/visualization/documentation/gallery/areachart.html" target="_blank">Area Chart</a>&#8216;.</p>
<p><span id="more-6"></span></p>
<p>All right and on good track, I skimmed through the documentation, used the sample code and got an initial satisfactory result. So far so good. The initial problem was with how the data is inputed and from the example given:</p>
<p><pre class="brush: jscript;">
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn('number', 'Expenses');
data.addRows(4);
data.setValue(0, 0, '2004');
data.setValue(0, 1, 1000);
data.setValue(0, 2, 400);
data.setValue(1, 0, '2005');
data.setValue(1, 1, 1170);
data.setValue(1, 2, 460);
data.setValue(2, 0, '2006');
data.setValue(2, 1, 660);
data.setValue(2, 2, 1120);
data.setValue(3, 0, '2007');
data.setValue(3, 1, 1030);
data.setValue(3, 2, 540);
</pre></p>
<p>This really doesn&#8217;t do the job and personally it&#8217;s tedious. That fixed array value is also a pain to work with. With all the buzz of JSON these days at first glance, I managed to get the data as a simpler chunk of code.</p>
<p><pre class="brush: jscript;">
var JSONObject = {
    cols: [
        {id: 'year', label: 'Year', type: 'string'},
        {id: 'sales', label: 'Sales', type: 'number'},
        {id: 'expenses', label: 'Expenses', type: 'number'}
    ],
    rows: [
        {c:[{v: '2004'}, {v: 1000}, {v: 400}]},
        {c:[{v: '2005'}, {v: 1170}, {v: 460}]},
        {c:[{v: '2006'}, {v: 660}, {v: 1120}]},
        {c:[{v: '2007'}, {v: 1030}, {v: 540}]}
    ]
};

var data = new google.visualization.DataTable(JSONObject, 0.6);
</pre></p>
<p><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">That is a much more like what I had in mind. With this setup, it&#8217;s much more easier to build up the data table needed to generate the chart. The object structure reference can be found <a title="JSON DataTable API Reference" href="http://code.google.com/apis/visualization/documentation/reference.html#DataTable" target="_blank">here</a>.</span></p>
<p>This concludes today&#8217;s post, but will come back and give some info on how to play with the options.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saviourc.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saviourc.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saviourc.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saviourc.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saviourc.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saviourc.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saviourc.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saviourc.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=6&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saviourc.wordpress.com/2009/09/19/joys-of-free-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e4e8a6b851659b0e957e8679f47f82e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saviourc</media:title>
		</media:content>
	</item>
		<item>
		<title>The Grand Opening!</title>
		<link>http://saviourc.wordpress.com/2009/09/17/hello-world/</link>
		<comments>http://saviourc.wordpress.com/2009/09/17/hello-world/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 23:08:08 +0000</pubDate>
		<dc:creator>saviourc</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hi and welcome to my blog. It&#8217;s 1:10 am in the morning and my eyes, body and head cannot do any more to keep me awake. I&#8217;ll be posting some interesting coding pieces I have encountered tonight by scrambling google&#8217;s free visualisation APIs. (if I don&#8217;t forget them) Till then, have a wonderful time.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=1&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi and welcome to my blog.</p>
<p>It&#8217;s 1:10 am in the morning and my eyes, body and head cannot do any more to keep me awake.</p>
<p>I&#8217;ll be posting some interesting coding pieces I have encountered tonight by scrambling google&#8217;s free visualisation APIs. (if I don&#8217;t forget them)</p>
<p>Till then, have a wonderful time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saviourc.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saviourc.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saviourc.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saviourc.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saviourc.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saviourc.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saviourc.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saviourc.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saviourc.wordpress.com&amp;blog=9538184&amp;post=1&amp;subd=saviourc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saviourc.wordpress.com/2009/09/17/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e4e8a6b851659b0e957e8679f47f82e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saviourc</media:title>
		</media:content>
	</item>
	</channel>
</rss>
