<?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>Tadek's Blog &#187; Databases</title>
	<atom:link href="http://tadek.pietraszek.org/blog/category/tipstricks/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://tadek.pietraszek.org/blog</link>
	<description>Some random notes about computers, security, cool links and others.</description>
	<lastBuildDate>Fri, 12 Dec 2008 22:49:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PostgreSQL8.1 &#8220;client encoding mismatch&#8221; with ODBC</title>
		<link>http://tadek.pietraszek.org/blog/2005/12/02/postgresql81-client-encoding-mismatch-with-odbc/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/12/02/postgresql81-client-encoding-mismatch-with-odbc/#comments</comments>
		<pubDate>Fri, 02 Dec 2005 13:09:03 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/?p=218</guid>
		<description><![CDATA[While connecting to PostgreSQL using UnixODBC (from R, but this doesn&#8217;t matter) I got the following error:

[unixODBC]client encoding mismatch


It seems that there is some problem with PostgreSQL 8.1 and the encoding names: see this post or google. It looks that UTF8 used by default with the new Postgres is not compatible with old ODBC drivers. [...]]]></description>
			<content:encoded><![CDATA[<p>While connecting to PostgreSQL using UnixODBC (from R, but this doesn&#8217;t matter) I got the following error:</p>

<pre><code>[unixODBC]client encoding mismatch
</code></pre>

<p>It seems that there is some problem with PostgreSQL 8.1 and the encoding names: see <a href="http://archives.postgresql.org/pgsql-odbc/2005-09/msg00161.php">this post</a> or <a href="http://www.google.com/search?q=%22client+encoding+mismatch%22+postgres">google</a>. It looks that UTF8 used by default with the new Postgres is not compatible with old ODBC drivers. I am not sure where the problem really is, but a <em>quick fix</em>  is to change default encoding for the user connecting to the database:</p>

<pre><code>alter user &lt;user&gt; SET client_encoding to LATIN1;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/12/02/postgresql81-client-encoding-mismatch-with-odbc/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PostgreSQL 8 performance tuning</title>
		<link>http://tadek.pietraszek.org/blog/2005/12/02/postgresql-8-performance-tuning/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/12/02/postgresql-8-performance-tuning/#comments</comments>
		<pubDate>Fri, 02 Dec 2005 10:29:23 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/?p=217</guid>
		<description><![CDATA[Here&#8217;s my list of pointers:


Power PostgreSQL &#8211; really detailed and up-to-date information on setting PostgreSQL runtime parameters. Don&#8217;t forget to check the annotated postgresql.conf with comments. BTW: Looking forward to reading the forthcoming book.
Collection of PostgreSQL performance tips &#8211; a shopping lists of tips (both configuration as well as application design). The posts is a [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s my list of pointers:</p>

<ul>
<li><a href="http://www.powerpostgresql.com/Docs/">Power PostgreSQL</a> &#8211; really detailed and up-to-date information on setting PostgreSQL runtime parameters. Don&#8217;t forget to check the annotated <a href="http://www.powerpostgresql.com/Downloads/annotated_conf_80.pdf">postgresql.conf</a> with comments. BTW: Looking forward to reading the forthcoming book.</li>
<li><a href="http://archives.postgresql.org/pgsql-sql/2002-04/msg00318.php">Collection of PostgreSQL performance tips</a> &#8211; a shopping lists of tips (both configuration as well as application design). The posts is a bit old, but many things (ecpesially the more general ones are still very relevant).</li>
<li><a href="http://www.revsys.com/writings/postgresql-performance.html">Performance Tuning PostgreSQL</a> &#8211; a decent link, explaining both runtime settings  (some of this might be obsolete) and the general concepts: <code>EXPLAIN</code>, <code>ANALYZE</code>, indices.</li>
<li><a href="http://developer.postgresql.org/docs/postgres/runtime-config.html">Postgres 8.x docs</a> &#8211; explains runtime parameters in some detail.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/12/02/postgresql-8-performance-tuning/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DB2 reference</title>
		<link>http://tadek.pietraszek.org/blog/2005/11/24/db2-reference/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/11/24/db2-reference/#comments</comments>
		<pubDate>Wed, 23 Nov 2005 22:53:12 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/11/24/db2-reference/</guid>
		<description><![CDATA[DB2 reference from IBM &#8211; might be useful one day.
]]></description>
			<content:encoded><![CDATA[<p>DB2 <a href="http://publib.boulder.ibm.com/infocenter/db2help/topic/com.ibm.db2.udb.doc/admin/r0011049.htm">reference</a> from IBM &#8211; might be useful one day.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/11/24/db2-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installig DB2 on Linux</title>
		<link>http://tadek.pietraszek.org/blog/2005/11/22/db2-related-links/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/11/22/db2-related-links/#comments</comments>
		<pubDate>Tue, 22 Nov 2005 13:05:50 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/11/22/db2-related-links/</guid>
		<description><![CDATA[A few links I found useful while installing DB2 on Debian/Gentoo, etc:


    An alternate method of installing DB2 on Unix platforms
    RedBook: Up and Running with DB2 on Linux

]]></description>
			<content:encoded><![CDATA[<p>A few links I found useful while installing DB2 on Debian/Gentoo, etc:</p>

<ul>
    <li><a href="http://www.scotdb.com/downloads/DB2V8SpecialInstall.pdf">An alternate method of installing DB2 on Unix platforms</a></li>
    <li><a href="http://publib-b.boulder.ibm.com/abstracts/sg246899.html?Open">RedBook: Up and Running with DB2 on Linux</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/11/22/db2-related-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grant privileges on all tables in one go</title>
		<link>http://tadek.pietraszek.org/blog/2005/11/21/grant-privileges-on-all-tables-in-one-go/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/11/21/grant-privileges-on-all-tables-in-one-go/#comments</comments>
		<pubDate>Sun, 20 Nov 2005 22:30:14 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/11/21/grant-privileges-on-all-tables-in-one-go/</guid>
		<description><![CDATA[PostgreSQL: Grant privileges on all tables in one go using shell scripts or stored procedures.
]]></description>
			<content:encoded><![CDATA[<p>PostgreSQL: <a href="http://www.archonet.com/pgdocs/grant-all.html">Grant privileges on all tables in one go</a> using shell scripts or stored procedures.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/11/21/grant-privileges-on-all-tables-in-one-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading Postgres 7.4 to 8.0 in Debian</title>
		<link>http://tadek.pietraszek.org/blog/2005/11/09/upgrading-postgres-74-to-80-in-debian/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/11/09/upgrading-postgres-74-to-80-in-debian/#comments</comments>
		<pubDate>Wed, 09 Nov 2005 16:52:39 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/11/09/upgrading-postgres-74-to-80-in-debian/</guid>
		<description><![CDATA[I recently had to upgrade my PostgreSQL 7.4 to 8.0 in Debian and learned that there is a cool way of doing this. This procedure is described in /usr/share/doc/postgresql-common/architecture.html.

In a nutshell:


    Install the new version in packages: postgresql-*-8.0. Mote that all the pg_* tools still point to the old versions.
   [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to upgrade my PostgreSQL 7.4 to 8.0 in Debian and learned that there is a cool way of doing this. This procedure is described in <code>/usr/share/doc/postgresql-common/architecture.html</code>.</p>

<p>In a nutshell:</p>

<ol>
    <li>Install the new version in packages: postgresql-*-8.0. Mote that all the pg_* tools still point to the old versions.</li>
    <li>Make sure that both servers are up and running.</li>
    <li>Run: &#8220;pg_upgradecluster 7.4 main&#8221; to upgrade the old database to the new one.</li>
    <li>Now all the pg_* tools point to the new versions, also the new server will listen on the standard port. Check if everything works fine.</li>
    <li>Run &#8220;pg_dropcluster 7.4 main&#8221; to  delete the old database.</li>
</ol>

<p>Cool. I wonder how Gentoo does this <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/11/09/upgrading-postgres-74-to-80-in-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DBAzine.com: SQL Views Transformed</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/28/dbazinecom-sql-views-transformed/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/28/dbazinecom-sql-views-transformed/#comments</comments>
		<pubDate>Fri, 28 Oct 2005 19:47:27 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/28/dbazinecom-sql-views-transformed/</guid>
		<description><![CDATA[All you wanted to know about views and materialized views in databases: DBAzine.com: SQL Views Transformed
]]></description>
			<content:encoded><![CDATA[<p>All you wanted to know about views and materialized views in databases: <a href="http://www.dbazine.com/db2/db2-disarticles/gulutzan9">DBAzine.com: SQL Views Transformed</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/28/dbazinecom-sql-views-transformed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL8.0 supports XML!</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/17/postgresql80-supports-xml/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/17/postgresql80-supports-xml/#comments</comments>
		<pubDate>Mon, 17 Oct 2005 12:15:54 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/?p=170</guid>
		<description><![CDATA[Cool. It looks that PostgreSQL8.0 supports XML as an additional extension (contrib driectory). In gentoo you can compile it specifying +xml2 option.

Now how to use it:
1. you need to create xml functions in a database using a supplied script, most typically
/usr/share/postgresql/contrib/pgxml.sql. Note that this script has been created (customized) by autoconf and contains a hard-coded [...]]]></description>
			<content:encoded><![CDATA[<p>Cool. It looks that PostgreSQL8.0 supports XML as an additional extension (contrib driectory). In gentoo you can compile it specifying +xml2 option.</p>

<p>Now how to use it:
1. you need to create xml functions in a database using a supplied script, most typically
/usr/share/postgresql/contrib/pgxml.sql. Note that this script has been created (customized) by autoconf and contains a hard-coded location of your pgxml.so library, typically: /usr/lib/postgresql/pgxml.so.</p>

<ol>
<li>If you get no error&#8230;. well that&#8217;s it <img src='http://tadek.pietraszek.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>

<p>See <a href="http://www.throwingbeans.org/postgresql_and_xml_updated.html">this link</a> and the documentation contrib/xml2 for more details.</p>

<p>BTW: If your database stores XML as binary strings (bytea) you must convert them to normal strings using encode(&lt;byteacolumn&gt;, &#8216;escape&#8217;);</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/17/postgresql80-supports-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slow aggergate queries in PostgreSQL</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/17/slow-aggergate-calculations-in-postgresql/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/17/slow-aggergate-calculations-in-postgresql/#comments</comments>
		<pubDate>Mon, 17 Oct 2005 11:29:15 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/?p=169</guid>
		<description><![CDATA[Postgres is strange.  If you make a query

select min(column_with_index) from table;

the database performs a sequential scan &#8211; you can only imagine how long it takes on a 10M record database. This seems to be a feature (!@!#!@), but indices can will used if you use the following workaround:

select column_with_index from table order by 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Postgres is strange.  If you make a query</p>

<p><code>select min(column_with_index) from table;</code></p>

<p>the database performs a <b>sequential scan</b> &#8211; you can only imagine how long it takes on a 10M record database. This seems to be a feature (!@!#!@), but indices can will used if you use the following workaround:</p>

<p><code>select column_with_index from table order by 1 (desc) limit 1;</code></p>

<p>This trick is explained <a href="http://www.postgresql.org/docs/faqs.FAQ.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/17/slow-aggergate-calculations-in-postgresql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PostgreSQL Autodoc</title>
		<link>http://tadek.pietraszek.org/blog/2005/10/08/postgresql-autodoc/</link>
		<comments>http://tadek.pietraszek.org/blog/2005/10/08/postgresql-autodoc/#comments</comments>
		<pubDate>Sat, 08 Oct 2005 09:19:37 +0000</pubDate>
		<dc:creator>tadekp</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Progs/Tools/Libs]]></category>

		<guid isPermaLink="false">http://tadek.pietraszek.org/blog/2005/10/08/postgresql-autodoc/</guid>
		<description><![CDATA[A drawing tool generaring UML diagrams from Postgresql database in DIA format, HTML and a few others. Not perfect, but quite neat and the diagrams can be eidted with DIA (there also exists a plugin to generate a schema from those DIA UML diagrams).

PostgreSQL Autodoc
]]></description>
			<content:encoded><![CDATA[<p>A drawing tool generaring UML diagrams from Postgresql database in DIA format, HTML and a few others. Not perfect, but quite neat and the diagrams can be eidted with DIA (there also exists a plugin to generate a schema from those DIA UML diagrams).</p>

<p><a href="http://www.rbt.ca/autodoc/">PostgreSQL Autodoc</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tadek.pietraszek.org/blog/2005/10/08/postgresql-autodoc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
