<?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>Blog - ShiftEleven &#187; Database</title>
	<atom:link href="http://shifteleven.com/articles/category/database/feed" rel="self" type="application/rss+xml" />
	<link>http://shifteleven.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 19 Sep 2009 11:19:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
		<item>
		<title>Making ActiveRecord faster by NOT indexing</title>
		<link>http://shifteleven.com/articles/2008/04/29/making-activerecord-faster-by-not-indexing</link>
		<comments>http://shifteleven.com/articles/2008/04/29/making-activerecord-faster-by-not-indexing#comments</comments>
		<pubDate>Tue, 29 Apr 2008 16:55:14 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[indexing]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[singletableinheritance]]></category>

		<guid isPermaLink="false">http://shifteleven.com/?p=64</guid>
		<description><![CDATA[Usually one of the first things I read about on how to speed up ActiveRecord is to index my columns to speed up the lookup of items.  &#8220;Of course!&#8221;  But could indexing too much be harmful
Essentially, if your column is an enum, then indexing it could actually cause MySQL to do more work. [...]]]></description>
			<content:encoded><![CDATA[<p>Usually one of the first things I read about on how to speed up ActiveRecord is to index my columns to speed up the lookup of items.  &#8220;Of course!&#8221;  <a href="http://www.mysqlperformanceblog.com/2007/08/28/do-you-always-need-index-on-where-column/?">But could indexing too much be harmful</a></p>
<p>Essentially, if your column is an enum, then indexing it could actually cause MySQL to do more work.  Why?  Because the data set is so large, the MySQL ends up doing a full scan.  So things like keeping track if something is active (1 or 0) then you can expect indexing to hurt.</p>
<p>So how does this effect ActiveRecord?  Well, if you&#8217;re keeping track of whether a user is active or not you would not want to index that column alone.  Nor would you want to index a <code>type</code> column if you were using single table inheritance, again, because there isn&#8217;t a lot of variance in the type.</p>
<p>So make sure that you index the right things, like IDs and leave the enum-like columns alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2008/04/29/making-activerecord-faster-by-not-indexing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PostgreSQL on Leopard using MacPorts</title>
		<link>http://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports</link>
		<comments>http://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports#comments</comments>
		<pubDate>Sat, 22 Mar 2008 03:41:36 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[pgadmin3]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://shifteleven.com/?p=43</guid>
		<description><![CDATA[I have always used MySQL but I wanted to give PostgreSQL a whirl.  This is what I did.

Prerequisites
Now I don&#8217;t want to go too deep into this, so I&#8217;m going to assume that if you are reading this, that you have the following installed

Mac OS Developer&#8217;s Tools
MacPorts
Ruby (comes with Leopard)

Ruby Gems (also comes with [...]]]></description>
			<content:encoded><![CDATA[<p>I have always used <a href="http://www.mysql.com/,">MySQL</a> but I wanted to give <a href="http://www.postgresql.org/">PostgreSQL</a> a whirl.  This is what I did.</p>
<p><span id="more-43"></span></p>
<h3>Prerequisites</h3>
<p>Now I don&#8217;t want to go too deep into this, so I&#8217;m going to assume that if you are reading this, that you have the following installed</p>
<ul>
<li><a href="http://developer.apple.com/tools/">Mac OS Developer&#8217;s Tools</a></li>
<li><a href="http://www.macports.org/install.php">MacPorts</a></li>
<li><a href="http://www.ruby-lang.org/">Ruby</a> (comes with Leopard)
<ul>
<li><a href="http://www.rubygems.org/">Ruby Gems</a> (also comes with Leopard)</li>
</ul>
</li>
</ul>
<p>So now that you have all of those dependencies out of the way, let&#8217;s get to installing us some PostgreSQL.</p>
<h3>PostgreSQL</h3>
<p>To install the database software, simply run the following command in <a href="http://www.apple.com/macosx/technology/unix.html">Terminal</a></p>
<pre>sudo port install \
  postgresql83 \
  postgresql83-server</pre>
<p>This will install the client and server needed for you to run this on your machine.  Now pay special attention to the installation script.  At the end of installation processes, macports will display a message for you that contains some commands for you to get started with.</p>
<h4>Configuration</h4>
<p>First, execute these lines of code.  This will setup a new database for you to play with</p>
<pre>sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'</pre>
<h4>Start PostgreSQL Automatically</h4>
<p>By running the next command, you can have PostgreSQL lunch automatically so that it&#8217;s always available to you</p>
<pre>sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist</pre>
<h3>pgAdmin III</h3>
<p><a href="http://www.pgadmin.org/">pgAdmin III</a> is a PostgreSQL management and administrations piece of software.  It&#8217;s a nice GUI to some things that you may find yourself wanting to do, like created databases and whatnot.  Installation of this is pretty cake.</p>
<pre>sudo port install pgAdmin3</pre>
<p>Upon completion of installation, you can find the application in <code>/Applications/MacPorts/pgAdmin3</code></p>
<h3>PostgreSQL Libraries for Ruby via Gems</h3>
<p>I have to admit, the previous installation steps were nothing to cry about; however, it was this step that made me want to put together this little walkthrough.</p>
<pre>sudo env ARCHFLAGS="-arch i386" \
  gem install postgres -- \
  --with-pgsql-lib=/opt/local/lib/postgresql83 \
  --with-pgsql-include=/opt/local/include/postgresql83</pre>
<p>That&#8217;s not exactly your everyday <code>gem install</code> command.  For one, the environment variable <code>ARCHFLAGS</code> has to be set.  Secondly, the <code>gem</code> command needs to know where the PostgreSQL  libraries and include headers are so that it can compile.  Looking back, it&#8217;s actually quite easy to copy and paste that command, it just took me a while to find out exactly what I needed to make it work.</p>
<h3>Fin</h3>
<p>Well, I hope that helps anyone looking to install and setup PostgreSQL in Leopard.  Until next time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports/feed</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
	</channel>
</rss>
