<?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>Velomatrix: Technically Speaking</title>
	<atom:link href="http://velomatrix.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://velomatrix.net</link>
	<description>Geek Talk</description>
	<lastBuildDate>Mon, 02 May 2011 14:56:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Ubuntu Does Not Reset MOTD after updating</title>
		<link>http://velomatrix.net/2011/05/02/ubuntu-does-not-reset-motd-after-updating/</link>
		<comments>http://velomatrix.net/2011/05/02/ubuntu-does-not-reset-motd-after-updating/#comments</comments>
		<pubDate>Mon, 02 May 2011 14:56:03 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[motd]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=77</guid>
		<description><![CDATA[After successfully updating my Ubuntu 10.04.02 64-bit VM with the usual: sudo apt-get update &#38;&#38; sudo apt-get upgrade The message of the day (MOTD) did not reset the number the number of packages that required updating. Mine was stuck on: 30 packages can be updated. 23 updates are security updates. To remedy this, clear out <a href='http://velomatrix.net/2011/05/02/ubuntu-does-not-reset-motd-after-updating/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>After successfully updating my Ubuntu 10.04.02 64-bit VM with the usual:</p>
<p><code>sudo apt-get update &amp;&amp; sudo apt-get upgrade</code></p>
<p>The message of the day (MOTD) did not reset the number the number of packages that required updating. Mine was stuck on:</p>
<p><code>30 packages can be updated.<br />
23 updates are security updates.</code></p>
<p>To remedy this, clear out <code>/etc/motd.tail</code> with this command:</p>
<p><code>cat /dev/null &gt; /etc/motd.tail</code></p>
<p>When you login again, all will be right with your MOTD.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/05/02/ubuntu-does-not-reset-motd-after-updating/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop Guest Ubuntu OS From Losing Time In VMWare Fusion</title>
		<link>http://velomatrix.net/2011/03/16/stop-guest-ubuntu-os-from-losing-time-in-vmware-fusion/</link>
		<comments>http://velomatrix.net/2011/03/16/stop-guest-ubuntu-os-from-losing-time-in-vmware-fusion/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 17:39:57 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[VM]]></category>
		<category><![CDATA[os-x]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=74</guid>
		<description><![CDATA[On my MacBook Air, the Ubuntu 10.04 VMWare guest OS was losing time whenever the Air went to sleep. To keep time synchronized between the host and guest, install VMWare Tools AND enable time synchronization by executing sudo /usr/bin/vmware-toolbox. Make sure the following checkbox is selected.]]></description>
			<content:encoded><![CDATA[<p>On my MacBook Air, the Ubuntu 10.04 VMWare guest OS was losing time whenever the Air went to sleep. To keep time synchronized between the host and guest, install VMWare Tools AND enable time synchronization by executing <code>sudo /usr/bin/vmware-toolbox</code>. Make sure the following checkbox is selected.<br />
<a href="http://velomatrix.net/wp-content/uploads/2011/03/vmware-tools-properties.png"><img class="alignnone size-full wp-image-75" src="http://velomatrix.net/wp-content/uploads/2011/03/vmware-tools-properties.png" alt="vmware tools properties dialog" width="404" height="434" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/03/16/stop-guest-ubuntu-os-from-losing-time-in-vmware-fusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving Bluetooth Disconnects</title>
		<link>http://velomatrix.net/2011/03/12/solving-bluetooth-disconnects/</link>
		<comments>http://velomatrix.net/2011/03/12/solving-bluetooth-disconnects/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 06:21:48 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[windows-7]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=72</guid>
		<description><![CDATA[Since its purchase, my primary Windows 7 laptop has suffered from random bluetooth disconnects to both the mouse and keyboard. Since the disconnects are almost always simultaneous, I suspected a problem in either the laptop&#8217;s bluetooth module or the software driver. After the latest frustrating disconnect, I once again sought an answer from the wisdom <a href='http://velomatrix.net/2011/03/12/solving-bluetooth-disconnects/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Since its purchase, my primary <a href="http://ezclip.net/gM1rBO">Windows 7 laptop</a> has suffered from random bluetooth disconnects to both the mouse and keyboard. Since the disconnects are almost always simultaneous, I suspected a problem in either the laptop&#8217;s bluetooth module or the software driver.</p>
<p>After the latest frustrating disconnect, I once again sought an answer from the wisdom of Google. This time, however, my queries proved fruitful. Disabling the power management features of the bluetooth module as detailed in this <a href="http://sherylcanter.com/wordpress/2010/01/bluetooth-mouse-losing-connection-no-more/">article</a> solved my bluetooth issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/03/12/solving-bluetooth-disconnects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reloading Your Development Database With a Single Command</title>
		<link>http://velomatrix.net/2011/03/09/reloading-your-development-database-with-a-single-command/</link>
		<comments>http://velomatrix.net/2011/03/09/reloading-your-development-database-with-a-single-command/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 04:10:58 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=68</guid>
		<description><![CDATA[Reloading your development database from a copy on the staging or production server can be done with a single command. With the magic of ssh, key pair authentication, and .my.cnf files on the server and your development box, you can execute the following: ssh -C username@remotehost.com 'mysqldump myapp_staging' &#124; mysql myapp_development Let&#8217;s examine the entire <a href='http://velomatrix.net/2011/03/09/reloading-your-development-database-with-a-single-command/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Reloading your development database from a copy on the staging or production server can be done with a single command. With the magic of <code>ssh</code>, key pair authentication, and .<code>my.cnf</code> files on the server and your development box, you can execute the following:</p>
<p><code>ssh -C username@remotehost.com 'mysqldump myapp_staging' | mysql myapp_development</code></p>
<p>Let&#8217;s examine the entire command in pieces. <code>ssh</code> followed by a command allows you to execute that remote command and have its output sent to the originating server&#8217;s <code>stdout</code>. <code>mysqldump myapp_staging</code> is executed on the remote server and the <code>-C</code> flag instructs <code>ssh</code> to compress the data from the remote server. Then, <code>mysql</code> executes locally to run the sql statements on the <code>myapp_development</code> database. Voilà, you have reloaded your development database with a copy from the staging server with a single command.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/03/09/reloading-your-development-database-with-a-single-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editing a Skype Message the Geeky Way</title>
		<link>http://velomatrix.net/2011/01/19/editing-a-skype-message-the-geeky-way/</link>
		<comments>http://velomatrix.net/2011/01/19/editing-a-skype-message-the-geeky-way/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 04:12:54 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=63</guid>
		<description><![CDATA[Apparently, this only works on the OS X and Linux versions of Skype. If you want to edit the last chat message you sent, you can use this syntax: s/mistaek/mistake/ Skype will then update the last message you sent. However, the recipient will see a message indicating that it was edited. This is equivalent to <a href='http://velomatrix.net/2011/01/19/editing-a-skype-message-the-geeky-way/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Apparently, this only works on the OS X and Linux versions of <a href="http://www.skype.com">Skype</a>. If you want to edit the last chat message you sent, you can use this syntax:</p>
<p><code>s/mistaek/mistake/</code></p>
<p>Skype will then update the last message you sent. However, the recipient will see a message indicating that it was edited. This is equivalent to right-clicking on the message and selecting Edit. However, for someone who uses <a href="http://www.vim.org/">vim</a> all day, this Skype feature is awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/01/19/editing-a-skype-message-the-geeky-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable one file per table for innodb in MySQL</title>
		<link>http://velomatrix.net/2011/01/08/enable-one-file-per-table-for-innodb-in-mysql/</link>
		<comments>http://velomatrix.net/2011/01/08/enable-one-file-per-table-for-innodb-in-mysql/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 06:23:11 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[disk-storage]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=58</guid>
		<description><![CDATA[I&#8217;m not sure why this setting is not enabled by default, but every MySQL installation should have this line in the [mysqld] section of its my.cnf file: innodb_file_per_table This setting instructs MySQL to create a separate file for each innodb table&#8217;s data. By default, MySQL stores all innodb data (from all databases) in a single file. <a href='http://velomatrix.net/2011/01/08/enable-one-file-per-table-for-innodb-in-mysql/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure why this setting is not enabled by default, but every <a href="http://www.mysql.com/">MySQL</a> installation should have this line in the <code>[mysqld]</code> section of its <code>my.cnf</code> file:</p>
<p><code>innodb_file_per_table</code></p>
<p>This setting instructs MySQL to create a separate file for each <a href="http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html">innodb</a> table&#8217;s data. By default, MySQL stores all innodb data (from all databases) in a single file.  Now recall that when you delete data from an innodb table, the actual disk storage is not recovered. Instead, MySQL marks the storage region so that when new data is added, that region can be re-used.  That is a sensible strategy, but fails miserably when you need to delete a lot data and recover the corresponding disk storage.</p>
<p>With a single file for all innodb data, recovering disk storage amounts to backing up the database, dropping and re-creating the database, and then reloading the database from the backup.  In the process, you have to stop your server and remove the <code>/var/lib/mysql/ibdata1</code> file.  This is rarely a viable strategy.  If you are in desperate need to recover disk space on your server, it&#8217;s doubtful that you have room to store the database backup.  Moreover, the backup and restore process is far from instantaneous when you&#8217;re dealing with hundreds of gigabytes of data.  This all amounts to a lot of downtime.</p>
<p>Do things right from the start.  Add <code>innodb_file_per_table</code> to your <code>my.cnf</code> file.  You will have to restart MySQL for this change to take effect. Now when you want to free up disk space, you can work at the granularity of a single table instead of all databases utilizing innodb.</p>
<p>For example, if you want to clear out the majority of a fictitious table named <code>really_big_table</code>, start by running an <code>INSERT SELECT</code> statement to store a copy of the data you want to keep into a temporary table.  Then <code>DROP really_big_table</code> and re-<code>CREATE</code> it.  Now load the data from the temporary table back into <code>really_big_table</code> via another <code>INSERT SELECT</code>.  Your disk storage has been recovered.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/01/08/enable-one-file-per-table-for-innodb-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access your VMware instance with NAT and a static IP address</title>
		<link>http://velomatrix.net/2011/01/07/access-your-vmware-instance-with-nat-and-a-static-ip-address/</link>
		<comments>http://velomatrix.net/2011/01/07/access-your-vmware-instance-with-nat-and-a-static-ip-address/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 07:08:20 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[VM]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[os-x]]></category>
		<category><![CDATA[phusion-passenger]]></category>
		<category><![CDATA[ruby-enterprise-edition]]></category>
		<category><![CDATA[ruby-on-rails]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vm]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=41</guid>
		<description><![CDATA[Once you have your development environment setup as a VMware VM, you will want to access it with applications running on your host OS.  For example, you want to test your new shiny Ruby on Rails web application (running in your VM) with Internet Explorer on Windows or Safari on OS X There are three ways <a href='http://velomatrix.net/2011/01/07/access-your-vmware-instance-with-nat-and-a-static-ip-address/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Once you have your <a href="http://velomatrix.net/2011/01/04/use-a-vm-for-your-development-environment/">development environment setup as a VMware VM</a>, you will want to access it with applications running on your host OS.  For example, you want to test your new shiny <a href="http://rubyonrails.org/">Ruby on Rails</a> web application (running in your VM) with Internet Explorer on Windows or Safari on OS X</p>
<p>There are three ways to configure the network connection for your VM:</p>
<ul>
<li>host-only</li>
<li>bridged</li>
<li><a href="http://en.wikipedia.org/wiki/Network_address_translation">NAT</a></li>
</ul>
<p>Host-only is not interesting for web applications that interact with APIs and services on the internet.</p>
<p>With a bridged connection and <a href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP</a>, your VM will have a different IP address as you go from home to office to coffee shop.  It becomes annoying to open a terminal in your VM, run <code>/sbin/ifconfig</code>, copy the IP address, and then go back to the host OS and adjust your <code>hosts</code> file accordingly.  Do this a few times and you will clamor for a better way.</p>
<p>Enter NAT and a static IP address for your VM.  You will have a consistent IP address no matter which network your host is on. Enter this IP address into your <code>hosts</code> file once and you&#8217;re done.  Let&#8217;s walk through a real life example.</p>
<p>You have 3 in-progress client projects.  You have configured your development VM with the same stack that&#8217;s powering your staging and production servers.   In this example, you have a Ruby on Rails application running <a href="http://projects.apache.org/projects/http_server.html">apache</a>, <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>, <a href="http://www.modrails.com/">Phusion Passenger</a>, and <a href="http://www.mysql.com/">MySQL</a>.  You configure each project with  its own VirtualHost : project1.dev, project2.dev, and project3.dev.  On your host OS, you have a <code>host</code> file entry like this:</p>
<p><code>192.168.154.100 project1.dev project2.dev project3.dev</code></p>
<p>Now whether you&#8217;re at home, at the office, or sipping some chai tea at a coffee shop, you can access your client projects the same way from a browser on the host OS: http://project1.dev, http://project2.dev, and http://project3.dev.</p>
<p>This seems simple enough, but it turns out that defining a static IP address in your guest Ubuntu VM and having that IP address accessible from the host is not trivial.  Start by running <code>ipconfig</code> (Windows) or <code>ifconfig</code> (OS X) on the host OS and look for the IPv4 Address for the VMnet8 adapter.  On my Windows machine, that address is 192.168.154.1.  On my OS X machine, that address is 172.16.252.1.</p>
<p>Now in your Ubuntu VM, configure it to use a static IP address.  This example uses 192.168.154 for the first three octets.  Substitute the first 3 octet values corresponding to your VMnet8 adapter.  In Ubuntu, System -&gt; Preferences -&gt; Network Connections.  On the Wired tab, select the network adapter (usually Auto eth1) and click on Edit.  Select the IPv4 Settings tab and enter/select these values:</p>
<ul>
<li>Method: Manual</li>
<li>IP address: 192.168.154.100</li>
<li>Netmask: 255.255.255.0</li>
<li>Gateway: 192.168.154.2</li>
<li>DNS Servers: 8.8.8.8, 8.8.4.4</li>
</ul>
<p>192.168.154.100 was chosen for the IP address because 100 is a) easy to remember and b) far enough away from the reserved low single digits to avoid conflicts.  The gateway value was the tricky one.  Most references instruct you to use the IP address, but substitute 1 for the final octet.  However, that IP address was already being used on the host for the VMnet8 adapter.  After much trial and error, it turned out that 192.168.154.2 was the ticket.  The DNS servers are Google&#8217;s.</p>
<p>After making the settings, restart your networking with <code>/etc/init.d/networking restart</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/01/07/access-your-vmware-instance-with-nat-and-a-static-ip-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use a VM for your development environment</title>
		<link>http://velomatrix.net/2011/01/04/use-a-vm-for-your-development-environment/</link>
		<comments>http://velomatrix.net/2011/01/04/use-a-vm-for-your-development-environment/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 05:08:21 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vm]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[windows-7]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=28</guid>
		<description><![CDATA[For many years, I developed software (mostly LAMP and Ruby on Rails) on a MacBook and MacBook Pro. It was always a struggle to have the right stack installed for various projects.  Mac Ports became my weapon of choice. Even then, there were enough differences between my development, staging, and production environments to cause unexpected <a href='http://velomatrix.net/2011/01/04/use-a-vm-for-your-development-environment/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>For many years, I developed software (mostly <a href="http://en.wikipedia.org/wiki/LAMP_(software_bundle)">LAMP</a> and <a href="http://rubyonrails.org/">Ruby on Rails</a>) on a <a href="http://ezclip.net/uW59rQ">MacBook</a> and <a href="http://ezclip.net/hzlftx">MacBook Pro</a>.  It was always a struggle to have the right stack installed for various projects.  <a href="http://www.macports.org/">Mac Ports</a> became my weapon of choice.  Even then, there were enough differences between my development, staging, and production environments to cause unexpected problems. Managing different versions of databases, libraries, etc. was never simple.</p>
<p>At the beginning of 2010, I was fed up with <a href="http://folklore.org/StoryView.py?story=Reality_Distortion_Field.txt">Steve Job&#8217;s reality distortion field</a> and defected back to the PC camp.  Greeting me with open arms was <a href="http://ezclip.net/40b4jH">Windows 7</a>, an OS that I continue to praise.  However, I longed for my bash prompt and open source stack.</p>
<p>The solution was to run a <a href="http://www.vmware.com/">VMware</a> VM with <a href="http://www.ubuntu.com/">Ubuntu</a> as the guest operating system.  This solved many problems.</p>
<ul>
<li>My development machine became consistent with my staging and production servers.</li>
<li>I can have a different VM for projects requiring different stacks.  No more trying to make my laptop a superset of all environments.</li>
<li>When bringing on additional developers to the project, I simply hand them a copy of the VM. Voilà.  Their entire development environment is ready to go.  No more wasting an entire day on configuring your laptop.</li>
<li>I chose VMware because it is available on Windows, OS X, and Linux and the same VM can run unaltered on all three platforms.</li>
<li>VMware offers snapshots, so you can easily roll back to a known state if you really mess things up.</li>
</ul>
<p>Now that it&#8217;s 2011, a client project requiring OS X has forced me back into Apple&#8217;s extortion pricing.  This time, however, I will be using the VM solution.  I highly recommend it.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/01/04/use-a-vm-for-your-development-environment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Querying Large Tables</title>
		<link>http://velomatrix.net/2011/01/04/querying-large-tables/</link>
		<comments>http://velomatrix.net/2011/01/04/querying-large-tables/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 15:50:07 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[partitioning]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=30</guid>
		<description><![CDATA[I recently completed an optimization pass for a website that does reporting for its clients. A number of reports took more than 30 seconds to compute. As the data grew, performance continued to degrade. The main table in question consisted of tens of millions of rows. Here was the strategy I employed: De-normalize the data <a href='http://velomatrix.net/2011/01/04/querying-large-tables/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I recently completed an optimization pass for a website that does reporting for its clients.  A number of reports took more than 30 seconds to compute.  As the data grew, performance continued to degrade.  The main table in question consisted of tens of millions of rows.</p>
<p>Here was the strategy I employed:</p>
<ol>
<li>De-normalize the data</li>
<li>Partition the  tables</li>
<li>Optimize the indexes on the table</li>
<li>Optimize the queries</li>
</ol>
<p>Step 1 is to avoid joins.  Joins are expensive operations.  If you can put all the necessary fields in a single table, your queries will also be much simpler and the database won&#8217;t have to perform complex operations.  Of course, nothing comes for fee.  The cost is duplication of data.  While space will rarely be your limiting factor, it&#8217;s important to take steps to avoid data inconsistencies.</p>
<p>Step 2 serves to divide your large table into smaller ones.  One huge advantage is that the indexes for any of the smaller tables will be much smaller.  If a table&#8217;s index can be loaded entirely into memory, you will notice huge speed improvements.  For this particular application, the database is <a href="http://www.postgresql.org/">Postgres</a> and I was able to utilize the <a href="http://www.postgresql.org/docs/current/interactive/ddl-inherit.html">inheritance</a> feature to implement <a href="http://www.postgresql.org/docs/8.4/static/ddl-partitioning.html">partitioning</a>.</p>
<p>Steps 3 and 4 really go hand-in-hand.  In an existing application, you have the luxury of examining the slow query logs to determine which queries to focus on.  On Postgres, I recommend using <a href="http://pgfouine.projects.postgresql.org/">pgFouine</a>.  As optimization is a never-ending pursuit, these two steps can take as little or as much time as you have.  Set realistic goals for your optimization efforts.  With Postgres, the <a href="http://www.postgresql.org/docs/8.4/static/sql-explain.html">explain analyze</a> command will yield vast amounts of data about your queries and the indexes.  Use them often.</p>
<p>This optimization effort allows reports that took in excess of 30 seconds to now return in under a second.</p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/01/04/querying-large-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show the current git branch in your bash prompt</title>
		<link>http://velomatrix.net/2011/01/04/show-the-current-git-branch-in-your-bash-prompt/</link>
		<comments>http://velomatrix.net/2011/01/04/show-the-current-git-branch-in-your-bash-prompt/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 08:05:38 +0000</pubDate>
		<dc:creator>ryin</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[branching]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://velomatrix.net/?p=21</guid>
		<description><![CDATA[git is the current hotness in source control. One of its main strengths is cheap and easy branching and merging. As a result, git users tend to use branches often. This is a good thing. However, when working on multiple repositories with multiple branches, it can be easy to lose track of your current branch. <a href='http://velomatrix.net/2011/01/04/show-the-current-git-branch-in-your-bash-prompt/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://git-scm.com/">git</a> is the current hotness in source control. One of its main strengths is cheap and easy branching and merging. As a result, git users tend to use branches often. This is a good thing. However, when working on multiple repositories with multiple branches, it can be easy to lose track of your current branch.</p>
<p>While a simple <code>git status</code> will yield the current branch, it is often convenient to have the current branch displayed in your prompt.  The magical incantation to add to your <code>PS1</code> variable is <code>$(__git_ps1)</code>.  This function is defined in <code>/etc/bash_completion.d/git</code>.  If you don&#8217;t have access to that file, you can find it in <code>contrib/completion/git-completion.bash</code> after cloning this repo:</p>
<p><code>git://git.kernel.org/pub/scm/git/git.git</code></p>
<p>Here is a snippet from a <code>.bashrc</code> file for displaying the current git branch in your bash prompt:<br />
<code><br />
source /etc/bash_completion.d/git<br />
export PS1='\w$(__git_ps1 "(%s)") &gt; '<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://velomatrix.net/2011/01/04/show-the-current-git-branch-in-your-bash-prompt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

