<?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>Life in the fast lane...</title>
	<atom:link href="http://shoaibmir.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://shoaibmir.wordpress.com</link>
	<description>by Shoaib Mir</description>
	<lastBuildDate>Wed, 18 Nov 2009 12:10:58 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='shoaibmir.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/d853f2aa84be87f1166bd5a62aa76283?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Life in the fast lane...</title>
		<link>http://shoaibmir.wordpress.com</link>
	</image>
			<item>
		<title>Implementing Yes/No to continue</title>
		<link>http://shoaibmir.wordpress.com/2009/11/18/implementing-yesno-to-continue/</link>
		<comments>http://shoaibmir.wordpress.com/2009/11/18/implementing-yesno-to-continue/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 11:57:12 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Do you want to continue]]></category>
		<category><![CDATA[Unix scripting]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=290</guid>
		<description><![CDATA[Here is a quick how-to for doing something like &#8220;Do you wish to continue Yes/No&#8221; within shell scripting:

 echo "Will you like to delete $dir under $PWD for a fresh extract? (y/n)"
 read opt
        case $opt in
            [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=290&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here is a quick how-to for doing something like &#8220;Do you wish to continue Yes/No&#8221; within shell scripting:</p>
<pre><code>
 echo "Will you like to delete $dir under $PWD for a fresh extract? (y/n)"
 read opt
        case $opt in<code>
                Y|y) cleanfolder $dir ;;
                [Yy][Ee][Ss]) cleanfolder $dir ;;
                N|n) exit ;;
                [Nn][Oo]) exit ;;
                *) exit;;
        esac
</code></pre>
<p>This will look for almost all kinds of combination of Yes/No options and do the appropriate action depending on the user input.</p>
<p>--<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=290&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/11/18/implementing-yesno-to-continue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Option parser in Python</title>
		<link>http://shoaibmir.wordpress.com/2009/11/18/option-parser-in-python/</link>
		<comments>http://shoaibmir.wordpress.com/2009/11/18/option-parser-in-python/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 11:46:26 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[option parser]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=286</guid>
		<description><![CDATA[I have just started playing around with Python like a few weeks back and having lots of fun scripting in it. Today at work got to know of a very nice feature with Python which lets you easily configure the options taken from command line, which is called option parser.
Firstly, you need to include the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=286&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have just started playing around with Python like a few weeks back and having lots of fun scripting in it. Today at work got to know of a very nice feature with Python which lets you easily configure the options taken from command line, which is called option parser.</p>
<p>Firstly, you need to include the library with &#8216;import&#8217;:</p>
<pre><code>from optparse import OptionParser</code></pre>
<p>Now you can use it like this:</p>
<pre><code>
usage = "usage: %prog -H hostname -p port -d diskpath -t threshold"
parser = OptionParser(usage=usage, version="%prog 1.0")
parser.add_option("-H", "--host", action="store", type="string", dest="hostname",
help="input host name for database server")
parser.add_option("-d", "--disk", action="store",
type="string", dest="diskpath", help="input disk path")
parser.add_option("-p", "--port", action="store", type="string",
dest="dbport", help="input port for database server")
parser.add_option("-t", "--thresh", action="store", type="int",
dest="thresh", help="input threshold for disk size ")
</code>
</pre>
<p>Where every <em>add_option</em> means adding a new argument on command line to check for and the best thing is you just put in the help section with the <em>add_option</em> function call and it automagically builds the full help section for the program to be use with &#8220;-h&#8221;, so that means you cant have an option with &#8220;-h&#8221; as that clashes with the default help option for option parser, and that was the reason I had to go with &#8220;-H&#8221; for hostname <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In order to get the values into variables just simply use:</p>
<pre><code>
(options, args) = parser.parse_args()
if options.hostname:
   hostname=options.hostname
if options.diskpath:
   diskpath=options.diskpath
if options.dbport:
   dbport=options.dbport
if options.thresh:
  thresh=options.thresh
</code></pre>
<p>Now when you run the program with &#8220;-h&#8221; option you get the following:</p>
<pre>
<code>
shoaib@shoaib-desktop:~/Desktop/Scripts$ ./mgmnt -h
Usage: mgmnt -H hostname -p port -d diskpath -t threshold
Options:
--version             show program's version number and exit
-h, --help            show this help message and exit
-H HOSTNAME, --host=HOSTNAME
input host name for database server
-d DISKPATH, --disk=DISKPATH
input disk path
-p DBPORT, --port=DBPORT
input port for database server
-t THRESH, --thresh=THRESH
input threshold for disk size
</code>
</pre>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/286/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/286/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/286/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=286&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/11/18/option-parser-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>GCC tricks for the Linux Kernel</title>
		<link>http://shoaibmir.wordpress.com/2009/11/03/gcc-tricks-for-the-linux-kernel/</link>
		<comments>http://shoaibmir.wordpress.com/2009/11/03/gcc-tricks-for-the-linux-kernel/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 15:06:10 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=281</guid>
		<description><![CDATA[While debugging some GCC specific linking problems, came across this very handy resource for gcc tips and tricks&#8230; very helpful indeed! 
Check it out at &#8211;&#62; http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/index.html
&#8211;
Shoaib Mir
shoaibmir[@]gmail.com
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=281&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>While debugging some GCC specific linking problems, came across this very handy resource for gcc tips and tricks&#8230; very helpful indeed! </p>
<p>Check it out at &#8211;&gt; <a href="http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/index.html">http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/index.html</a></p>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/281/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=281&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/11/03/gcc-tricks-for-the-linux-kernel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Disable notification system in Ubuntu</title>
		<link>http://shoaibmir.wordpress.com/2009/11/03/disable-notification-systems-in-ubuntu/</link>
		<comments>http://shoaibmir.wordpress.com/2009/11/03/disable-notification-systems-in-ubuntu/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 14:05:12 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[notification]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=274</guid>
		<description><![CDATA[I dont know about everyone else but for some reason I just found the notification system really annoying with my Ubuntu setup, after struggling with a few files and settings finally was able to get it all disabled.
Here is a quick how-to in case someone wants to disable/enable it&#8230;.
For disabling use the following:
sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service
/usr/share/dbus-1/services/org.freedesktop.Notifications.service.disabled
To [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=274&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I dont know about everyone else but for some reason I just found the notification system really annoying with my Ubuntu setup, after struggling with a few files and settings finally was able to get it all disabled.</p>
<p>Here is a quick how-to in case someone wants to disable/enable it&#8230;.</p>
<p>For disabling use the following:</p>
<pre>sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service
/usr/share/dbus-1/services/org.freedesktop.Notifications.service.disabled</pre>
<p>To re-enable it:</p>
<pre>sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service.
disabled /usr/share/dbus-1/services/org.freedesktop.Notifications.service</pre>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/274/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=274&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/11/03/disable-notification-systems-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting within psql</title>
		<link>http://shoaibmir.wordpress.com/2009/11/02/scripting-within-psql/</link>
		<comments>http://shoaibmir.wordpress.com/2009/11/02/scripting-within-psql/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:55:45 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[pgstattuple]]></category>
		<category><![CDATA[PSQL]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=261</guid>
		<description><![CDATA[In one of my previous posts I was told of using PSQL instead of shell scripting to make things much simpler. That turned out to a good tip and with some help from my colleague at work I am now so used to PSQL in these kind of scenarios.
Just today I had to get the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=261&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In one of my previous posts I was told of using PSQL instead of shell scripting to make things much simpler. That turned out to a good tip and with some help from my colleague at work I am now so used to PSQL in these kind of scenarios.</p>
<p>Just today I had to get the dead tuple percentages (using pgstattuple contrib) for tables within all databases on the server and here is how I was to get it done using PSQL and a simple shell script&#8230;.</p>
<pre>#!/bin/bash
PSQL="psql -A -t"
DBLIST=$($PSQL postgres -c "select datname from pg_database
where not datistemplate and datname not in ('postgres')")
for DB in $DBLIST; do
 echo $DB;
 psql $DB  &lt; gettupd.sql &gt; $DB.out
done
exit 0
</pre>
<p><strong>gettupd.sql</strong></p>
<pre>\a
\t
\o /tmp/tupd.sql
select 'SELECT \'' || relname || '\', * from pgstattuple('''||schemaname||
'.'||relname||''');' from pg_stat_user_tables ;
\o
\i /tmp/tupd.sql
\! rm /tmp/tupd.sql
\a
\t
</pre>
<p>PSQL is just the way to go&#8230;  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=261&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/11/02/scripting-within-psql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>A quick way to change index tablespace</title>
		<link>http://shoaibmir.wordpress.com/2009/09/29/a-quick-way-to-change-index-tablespace/</link>
		<comments>http://shoaibmir.wordpress.com/2009/09/29/a-quick-way-to-change-index-tablespace/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 10:26:57 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[move disk]]></category>
		<category><![CDATA[tablepsace]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=248</guid>
		<description><![CDATA[On one of the database servers, I had to quickly move all indexes from all the databases on to a different disk in order to free up some space from the main disk. I thought of sharing it so that someone else wanting to do the same thing can get an idea for doing the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=248&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>On one of the database servers, I had to quickly move all indexes from all the databases on to a different disk in order to free up some space from the main disk. I thought of sharing it so that someone else wanting to do the same thing can get an idea for doing the same&#8230;.</p>
<p>A quick how to,</p>
<p>First made a query to get all the indexes within a database using the following:</p>
<pre>select pg_namespace.nspname||'.'||pg_class.relname  from pg_class, pg_namespace
where pg_class.relnamespace  = pg_namespace.oid and pg_class.relkind = 'i' and pg_class.relname
not like 'pg_%'</pre>
<p>and then using a simple script, plugging in the the above mentioned query to do an ALTER INDEX for each index by setting the new table space:</p>
<pre>#!/bin/bash
DNAME_LIST=$(psql postgres -A -t -c "select datname from pg_database where
not datistemplate and datname != 'postgres'")
for DATABASE in $DNAME_LIST; do
INAME_LIST=$($PSQL $DATABASE -A -t -c "select pg_namespace.nspname||'.'||pg_class.relname
from pg_class, pg_namespace where
pg_class.relnamespace  = pg_namespace.oid and pg_class.relkind = 'i' and pg_class.relname
not like 'pg_%'")
    ( for INDEX in $INAME_LIST; do echo "ALTER INDEX $INDEX SET TABLESPACE
new_disk_index;"; done ) | psql $DATABASE
done</pre>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=248&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/09/29/a-quick-way-to-change-index-tablespace/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Row size and Btree index</title>
		<link>http://shoaibmir.wordpress.com/2009/09/23/row-size-and-btree-index/</link>
		<comments>http://shoaibmir.wordpress.com/2009/09/23/row-size-and-btree-index/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 11:10:24 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[btree]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[row size]]></category>
		<category><![CDATA[text search]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=243</guid>
		<description><![CDATA[At work today saw an error while inserting data into a table:
ERROR: index row size 2962 exceeds btree maximum, 2713
Looking at the HINT in the error, found out that you cant have the row size of more then 1/3th of the PostgreSQL block size (8K by default) for a btree index on the column.
The best [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=243&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>At work today saw an error while inserting data into a table:</p>
<pre>ERROR: index row size 2962 exceeds btree maximum, 2713</pre>
<p>Looking at the HINT in the error, found out that you cant have the row size of more then 1/3th of the PostgreSQL block size (8K by default) for a btree index on the column.</p>
<p>The best is to start using PostgreSQL full text search option for these kind of scenarios as it will be much faster and easier&#8230; but in my case that was not an option so had to somehow get around this problem without using text search engine.</p>
<p>After a little bit of research two possible solutions I could find out were (where column was of text data type):</p>
<p>-  Create a hash index on the same column as it will let you store more then 1/3rd of the block size, but a couple of things you need to consider before you go that route&#8230;</p>
<ul>
<li>It lets you get the data inserted for more then the 1/3rd of the block size but that again has limitation, you cant go above the PG block size and even closer to that.</li>
<li>With Hash indexing you wont be able to use the text pattern matching functions &#8220;LIKE&#8221; and &#8220;ILIKE&#8221;, you are left with &#8220;=&#8221;</li>
</ul>
<p>-  The other solution is to use the partial index where CREATE INDEX  will look something like this&#8230;</p>
<pre>        create index .... where length(clm_name) &lt; 500</pre>
<p>&#8230;this will require changing the queries as well, now you will have to add &#8220;where length(clm_name) &lt; 500&#8243; while doing SELECTS.</p>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
<pre></pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/243/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=243&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/09/23/row-size-and-btree-index/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding top read tables in the database</title>
		<link>http://shoaibmir.wordpress.com/2009/09/13/finding-top-read-tables-in-the-database/</link>
		<comments>http://shoaibmir.wordpress.com/2009/09/13/finding-top-read-tables-in-the-database/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 11:56:51 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[pg_stat_all_tables]]></category>
		<category><![CDATA[top read tables]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=220</guid>
		<description><![CDATA[A quick and good way to find the most used tables in a database with regards to reads can be:
PostgreSQL provides a system catalog view &#8220;pg_stat_all_tables&#8221; for helping DBAs with finding such statistics.
The view looks like this:
Columns
-------------
relid
relname
seq_scan
seq_tup_read
idx_scan
idx_tup_fetch
n_tup_ins
n_tup_upd
n_tup_del
This view has one entry for each table in the database. The seq_scan column tells you how many sequential [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=220&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A quick and good way to find the most used tables in a database with regards to reads can be:</p>
<p>PostgreSQL provides a system catalog view &#8220;<em>pg_stat_all_tables</em>&#8221; for helping DBAs with finding such statistics.</p>
<p>The view looks like this:</p>
<pre>Columns
-------------
relid
relname
seq_scan
seq_tup_read
idx_scan
idx_tup_fetch
n_tup_ins
n_tup_upd
n_tup_del</pre>
<p>This view has one entry for each table in the database. The <em>seq_scan</em> column tells you how many sequential scans have been performed for a given table and <em>seq_tup_read</em> tells you how many rows were used during those sequence scan. The <em>idx_scan</em> and <em>idx_tup_fetch</em> gives the same kind of information for the index scan usage. The <em>n_tup_ins, n_tup_upd </em>and <em>n_tup_del</em> gives you information on how many rows were inserted, update and deleted.</p>
<p>We can use this view in the following way to get the top 10 most read tables&#8230;</p>
<pre><em>SELECT relname, idx_tup_fetch + seq_tup_read as TotalReads</em><em> from pg_stat_all_tables
WHERE idx_tup_fetch + seq_tup_read != 0
order by TotalReads desc
LIMIT 10;</em></pre>
<pre>(With thanks to my favorite book "PostgreSQL by Korry Douglas")</pre>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/220/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=220&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/09/13/finding-top-read-tables-in-the-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting IMG files to Virtual Box VDI format</title>
		<link>http://shoaibmir.wordpress.com/2009/09/13/converting-img-files-to-virtual-box-vdi-format/</link>
		<comments>http://shoaibmir.wordpress.com/2009/09/13/converting-img-files-to-virtual-box-vdi-format/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 08:47:47 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Convert]]></category>
		<category><![CDATA[IMG]]></category>
		<category><![CDATA[VDI]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=216</guid>
		<description><![CDATA[In order to avoid installing the whole VM myself, I got an IMG file from a colleague for the CentOS VM. Now once I had the IMG file, but had not in the past converted it before to a VirtualBox compatible VDI format&#8230; after doing a little bit of research I found that to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=216&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In order to avoid installing the whole VM myself, I got an IMG file from a colleague for the CentOS VM. Now once I had the IMG file, but had not in the past converted it before to a VirtualBox compatible VDI format&#8230; after doing a little bit of research I found that to be a very simple process, so thought of sharing it with anyone who will like to do the same&#8230;.</p>
<p>Once you have the .img file just run the following from command line:</p>
<pre><em>VBoxManage convertfromraw -format VDI [filename].img [filename].vdi</em></pre>
<p>Depending on the size of .img file it might take a little while as for my desktop machine it took like around 5 minutes for converting a 4GB img file to vdi format. Once its all done just add the VDI file as another disk, attach it to a VM in VirtualBox&#8230; start the VM and you just got it all working <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=216&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/09/13/converting-img-files-to-virtual-box-vdi-format/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring SSH access for VirtualBox Guest Host</title>
		<link>http://shoaibmir.wordpress.com/2009/09/13/configuring-ssh-access-for-virtualbox-guest-host/</link>
		<comments>http://shoaibmir.wordpress.com/2009/09/13/configuring-ssh-access-for-virtualbox-guest-host/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 08:36:03 +0000</pubDate>
		<dc:creator>shoaibmir</dc:creator>
				<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[NAT]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://shoaibmir.wordpress.com/?p=213</guid>
		<description><![CDATA[A few days back at work, I had to configure a CentOS VM and after I was done with installation on the host itself under VirtualBox I tried doing SSH to the CentOS VM and it didnt let me do that. I had it all configured with NAT and never thought that it will give [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=213&subd=shoaibmir&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A few days back at work, I had to configure a CentOS VM and after I was done with installation on the host itself under VirtualBox I tried doing SSH to the CentOS VM and it didnt let me do that. I had it all configured with NAT and never thought that it will give me such a problem, googling it for a little while for an answer I found the solution&#8230; here is a quick howto for setting up SSH access to a VirutalBox VM:</p>
<p>Let <em>&lt;VMname&gt;</em> be the guest machine name (use quotes if it contains spaces), here are the commands that you have to execute for host machine console:</p>
<pre><em>$ VBoxManage setextradata &lt;VMname&gt; "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
$ VBoxManage setextradata &lt;VMname&gt; "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
$ VBoxManage setextradata &lt;VMname&gt; "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP</em></pre>
<p>The HostPort must be greater than or equal to 1024 since listening on ports 0-1023 needs root permssions (and Virtualbox usually doesn’t).</p>
<p>Once all goes good with the commands, you need to exit out (close it) of the guest Machine (different from a reboot as a reboot will not be enough in this case), restart it and then connect via ssh with:</p>
<pre><em>$ ssh -l username -p 2222 localhost</em><em></em></pre>
<p>Replace &#8220;localhost&#8221; with the host machine IP address if you are connecting from another computer.</p>
<p>&#8211;<br />
Shoaib Mir<br />
shoaibmir[@]gmail.com</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shoaibmir.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shoaibmir.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shoaibmir.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shoaibmir.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shoaibmir.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shoaibmir.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shoaibmir.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shoaibmir.wordpress.com/213/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shoaibmir.wordpress.com/213/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shoaibmir.wordpress.com/213/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shoaibmir.wordpress.com&blog=6056447&post=213&subd=shoaibmir&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://shoaibmir.wordpress.com/2009/09/13/configuring-ssh-access-for-virtualbox-guest-host/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9103cd68b066be8c8715bb5facf86bd2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shoaibmir</media:title>
		</media:content>
	</item>
	</channel>
</rss>