<?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>entwicklungsgedanken &#187; SQL</title>
	<atom:link href="http://www.entwicklungsgedanken.de/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.entwicklungsgedanken.de</link>
	<description>Verschiedene Gedanken rund um die Softwareentwicklung</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:09:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Solving NULL values are recognized as text-values within dynamic queries in PostgresSQL</title>
		<link>http://www.entwicklungsgedanken.de/2010/07/29/solving-null-values-are-recognized-as-text-values-within-dynamic-queries-in-postgressql/</link>
		<comments>http://www.entwicklungsgedanken.de/2010/07/29/solving-null-values-are-recognized-as-text-values-within-dynamic-queries-in-postgressql/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 11:09:20 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[dynamic query]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[NULL]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/?p=435</guid>
		<description><![CDATA[I&#8217;ve written a dynamic query which is finally executed via EXECUTE my_dynamic_query; The query contained a select list in which two columns should always be NULL. -- ... stuff before dynamic_select_cols := 'tbl1.foo, tbl1.bar, null AS theAlias1, null AS theAlias2, tbl2.foo2'; -- ... stuff after combining the dynamic queries EXECUTE my_dynamic_query; In my case the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a dynamic query which is finally executed via <code>EXECUTE my_dynamic_query;</code> The query contained a select list in which two columns should always be <code>NULL</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- ... stuff before</span>
dynamic_select_cols :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'tbl1.foo, tbl1.bar, null AS theAlias1, null AS theAlias2, tbl2.foo2'</span>;
<span style="color: #808080; font-style: italic;">-- ... stuff after combining the dynamic queries</span>
EXECUTE my_dynamic_query;</pre></div></div>

<p>In my case the result of the query will be inserted in a <a href="http://www.postgresql.org/docs/8.4/interactive/sql-createtable.html">temporary table</a> in memory. The destination column for <code>theAlias1</code> is of type <code>INTEGER</code>. When executing the query PostgreSQL gives me an error:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">column <span style="color: #ff0000;">&quot;theAlias1&quot;</span> is of <span style="color: #7a0874; font-weight: bold;">type</span> integer but expression is of <span style="color: #7a0874; font-weight: bold;">type</span> text</pre></div></div>

<p>So there is something wrong when the query is parsed, evaluated and executed.</p>
<p>Solving this was easy with the use of <a href="http://www.postgresql.org/docs/8.4/interactive/functions-conditional.html">NULLIF</a>. Zero equals zero so <code>NULL</code> is returned. Just as expected.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- ... stuff before</span>
dynamic_select_cols :<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'tbl1.foo, tbl1.bar, NULLIF(0, 0) AS theAlias1, NULLIF(0, 0) AS theAlias2, tbl2.foo2'</span>;
<span style="color: #808080; font-style: italic;">-- ... stuff after combining the dynamic queries</span>
EXECUTE my_dynamic_query;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2010/07/29/solving-null-values-are-recognized-as-text-values-within-dynamic-queries-in-postgressql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WITH-Klausel</title>
		<link>http://www.entwicklungsgedanken.de/2010/04/15/with-klausel/</link>
		<comments>http://www.entwicklungsgedanken.de/2010/04/15/with-klausel/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 09:52:00 +0000</pubDate>
		<dc:creator>clausbajor</dc:creator>
				<category><![CDATA[Datenbank]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Verschiedenes]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2010/04/15/with-klausel/</guid>
		<description><![CDATA[In der Praxis trifft man von Zeit zu Zeit auf aufgeblaehte SQL-Queries, die ausserordentlich kostenintensiven und langwierigen Ausfuehrungsplaenen folgen. Zeigt eine weitergehende Analyse, dass die komplexe Abfrage eine oder mehrere Subqueries enthaelt, die mehrfach ausgefuehrt werden, dann besteht eine sehr gute Chance durch Verwendung der sogenannten WITH-Klausel, die Performance der Abfrageausfuehrung erheblich zu steigern. Im [...]]]></description>
			<content:encoded><![CDATA[<p>In der Praxis trifft man von Zeit zu Zeit auf aufgeblaehte SQL-Queries, die ausserordentlich kostenintensiven und langwierigen Ausfuehrungsplaenen folgen.    <br />Zeigt eine weitergehende Analyse, dass die komplexe Abfrage eine oder mehrere Subqueries enthaelt, die mehrfach ausgefuehrt werden, dann besteht eine sehr     <br />gute Chance durch Verwendung der sogenannten WITH-Klausel, die Performance der Abfrageausfuehrung erheblich zu steigern. </p>
<p>Im Kern wird die schnellere Ausfuehrung der Query dadurch realisiert, dass mittels der WITH-Klausel die Ergebnismenge der Subquery vorab materialisiert, mit einem Namen versehen und schliesslich in der Hauptquery abgegriffen wird.    <br />Hier lohnt sich auch ein Vergleich und Gebrauch von &quot;global temporary tables&quot;, die in Ihrer Funktions- und Wirkungsweise durchaus ähnlich sind:     <br />Durch Entkopplung geeigneter Subqueries, die urspruenglich als Bestandteile einer komplexen Abfrage fungierten, wird dieses SQL-Statement vereinfacht.</p>
</p>
<div class="wp_syntax" style="padding-bottom: 0px">
<div class="code">
<pre style="font-family: monospace">
WITH   SQ1 AS (SELECT...FROM...WHERE...),
       SQ2 AS (SELECT...FROM...WHERE...)
SELECT...
  FROM Q1, SQ1, SQ2 WHERE…</pre>
</p></div>
</div>
<p>Interessanter Nebeneffekt:</p>
<p>Durch die Verwendung der WITH-Klausel wird anscheinend in einer Systemumgebung mit voreingestelltem CURSOR_SHARING=FORCE offensichtlich fuer die Query-Ausfuehrung diese systemweit gueltige Einstellung auf CURSOR_SHARING=EXACT zurueckgenommen (vergleichbar dem Einsatz des Hint /*+ cursor_sharing_exact */).</p>
<p>Zeigen die QEPs vorher noch eine allgemeine Ersetzung von Konstanten durch Parameter, so weisen die QEPs nachher die direkte Verwendung der Konstanten auf.</p>
<p>Somit orientiert sich der Optimizer auch grundsaetzlich an anderen Zugriffsstrategien.</p>
<p>Was in einer Umgebung mit problematischem Parseverhalten per Bindvariablen-Peeking einen &quot;flüssigen&quot; Anwendungsbetrieb ermöglichen kann, wird im Einzelfall einer komplexen Query unter Verwendung von Attributen mit stark ungleicher Werteverteilung zu relativ kostenintensiven QEPs führen. </p>
<p>Es empfiehlt sich dann für alle entsprechenden Konstanten/Parameter einen separaten und speziellen QEP zu erzwingen. </p>
<p>Vorraussetzung: </p>
<p>SQL-99 Standard bzw. Oracle9i Release 2</p>
<p>Links:</p>
<p><a title="SQLStandards.html" href="http://www.wiscorp.com/SQLStandards.html" target="_blank">SQLStandards.html</a> </p>
<p>to be continued….</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2010/04/15/with-klausel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MIN, MAX innerhalb eines SELECT-Statement</title>
		<link>http://www.entwicklungsgedanken.de/2010/04/05/min-max-innerhalb-eines-select/</link>
		<comments>http://www.entwicklungsgedanken.de/2010/04/05/min-max-innerhalb-eines-select/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 08:01:00 +0000</pubDate>
		<dc:creator>Sven Thämar</dc:creator>
				<category><![CDATA[Datenbank]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[min max sql]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2010/01/24/min-max-innerhalb-eines-select/</guid>
		<description><![CDATA[Manchmal benötigten man sowohl den kleinsten (min) als auch den größten (max) Wert einer indizierten Spalte gleichzeitig. SELECT MIN(id) , MAX(id) FROM big_table Bei diesem SELECT kommt zwar das richtige Ergebnis, dennoch kann die Antwortzeit sehr lange dauern. Der Grund liegt in einem FAST FULL INDEX SCAN. Besser ist folgendes: SELECT MIN(id) min_value FROM big_table [...]]]></description>
			<content:encoded><![CDATA[<p>Manchmal benötigten man sowohl den kleinsten (min) als auch den größten (max) Wert einer indizierten Spalte gleichzeitig.</p>
<p> </br>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">
SELECT MIN(id)
     , MAX(id)
  FROM big_table
</pre>
</div>
</div>
<p>Bei diesem SELECT kommt zwar das richtige Ergebnis, dennoch kann die Antwortzeit sehr lange dauern. Der Grund liegt in einem FAST <strong>FULL</strong> INDEX SCAN.</p>
<p>Besser ist folgendes:</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">
SELECT MIN(id) min_value
  FROM big_table
 UNION ALL
SELECT MAX(id) max_value
  FROM big_table
</pre>
</div>
</div>
<p>oder</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">SELECT (SELECT MIN(id) from big_table) min_value
      ,(SELECT MAX(id) from big_table) max_value
  FROM dual
</pre>
</div>
</div>
<p>Bei beiden alternativen wird ein FULL INDEX SCAN durchgeführt und liefert das Ergebnis (fast) sofort zurück.<br />
Den Umweg sollte man bei großen Tabellen und wo es auf Geschwindigkeit ankommt wählen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2010/04/05/min-max-innerhalb-eines-select/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blockierende SQL-Session</title>
		<link>http://www.entwicklungsgedanken.de/2010/04/05/blockierende-sql-session/</link>
		<comments>http://www.entwicklungsgedanken.de/2010/04/05/blockierende-sql-session/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 07:59:00 +0000</pubDate>
		<dc:creator>Sven Thämar</dc:creator>
				<category><![CDATA[Datenbank]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Verschiedenes]]></category>
		<category><![CDATA[Blockierende SQL Session]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2010/01/24/blockierende-sql-session/</guid>
		<description><![CDATA[Folgendes SQL-Statement kann man verwenden wenn man prüfen möchte ob es blockierende Sitzungen gibt. SELECT , b.username blocking_username , b.osuser blocking_osuser , b.machine blocking_machine , b.program blocking_program , w.sid waiting_sid , w.username waiting_username , w.osuser waiting_osuser , w.machine waiting_machine , w.seconds_in_wait FROM v$SESSION w , v$SESSION b WHERE w.blocking_session is not NULL AND b.sid = [...]]]></description>
			<content:encoded><![CDATA[<p>Folgendes SQL-Statement kann man verwenden wenn man prüfen möchte ob es blockierende Sitzungen gibt.</p>
<p> </br>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">
SELECT
     , b.username blocking_username
     , b.osuser blocking_osuser
     , b.machine blocking_machine
     , b.program blocking_program
     , w.sid waiting_sid
     , w.username waiting_username
     , w.osuser waiting_osuser
     , w.machine waiting_machine
     , w.seconds_in_wait
  FROM v$SESSION w
     , v$SESSION b
 WHERE w.blocking_session is not NULL
   AND b.sid = w.blocking_session
 ORDER BY w.sid
</pre>
</div>
</div>
<p>Das Statement kann jederzeit um weitere Spalten erweitert werden.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2010/04/05/blockierende-sql-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sortierung von hierachischen B&#228;umen</title>
		<link>http://www.entwicklungsgedanken.de/2010/04/05/sortierung-von-hierachischen-bumen/</link>
		<comments>http://www.entwicklungsgedanken.de/2010/04/05/sortierung-von-hierachischen-bumen/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 07:58:00 +0000</pubDate>
		<dc:creator>Sven Thämar</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sortieren; hierachische Bäume;]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2010/03/31/sortierung-von-hierachischen-bumen/</guid>
		<description><![CDATA[Oft hat man die Anforderung hierachische Bäume sortiert darzustellen. Am besten soll die Sortierung auch jederzeit geändert werden können. Folgendes Beispiel soll die einfache Lösung aufzeigen: SELECT a.id , a.parent_id , a.label , a.sort FROM menu_tree a ORDER BY 2 nulls first,1 &#160; ID PARENT_ID LABEL SORT 1 &#160; Anwendung 1 2 1 Hilfsdaten 2 [...]]]></description>
			<content:encoded><![CDATA[<p>Oft hat man die Anforderung hierachische Bäume sortiert darzustellen. Am besten soll die Sortierung auch jederzeit geändert werden können.</p>
<p>Folgendes Beispiel soll die einfache Lösung aufzeigen:</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">
SELECT a.id
     , a.parent_id
     , a.label
     , a.sort
  FROM menu_tree a
 ORDER BY 2 nulls first,1
</pre>
</div>
</div>
<p>&#160;</p>
<table border="1" cellspacing="0" cellpadding="2" width="386">
<tbody>
<tr>
<td valign="top" width="44">ID</td>
<td valign="top" width="78">PARENT_ID</td>
<td valign="top" width="213">LABEL</td>
<td valign="top" width="49">SORT</td>
</tr>
<tr>
<td valign="top" width="44">1</td>
<td valign="top" width="78">&#160;</td>
<td valign="top" width="213">Anwendung</td>
<td valign="top" width="49">1</td>
</tr>
<tr>
<td valign="top" width="44">2</td>
<td valign="top" width="78">1</td>
<td valign="top" width="213">Hilfsdaten</td>
<td valign="top" width="49">2</td>
</tr>
<tr>
<td valign="top" width="44">3</td>
<td valign="top" width="78">1</td>
<td valign="top" width="213">System</td>
<td valign="top" width="49">3</td>
</tr>
<tr>
<td valign="top" width="44">8</td>
<td valign="top" width="78">1</td>
<td valign="top" width="213">Berichte</td>
<td valign="top" width="49">1</td>
</tr>
<tr>
<td valign="top" width="44">5</td>
<td valign="top" width="78">2</td>
<td valign="top" width="213">Währung</td>
<td valign="top" width="49">3</td>
</tr>
<tr>
<td valign="top" width="44">6</td>
<td valign="top" width="78">2</td>
<td valign="top" width="213">Buchungsgründe</td>
<td valign="top" width="49">1</td>
</tr>
<tr>
<td valign="top" width="44">7</td>
<td valign="top" width="78">2</td>
<td valign="top" width="213">Kostenstellen</td>
<td valign="top" width="49">2</td>
</tr>
<tr>
<td valign="top" width="44">4</td>
<td valign="top" width="78">3</td>
<td valign="top" width="213">Anmelden</td>
<td valign="top" width="49">1</td>
</tr>
</tbody>
</table>
<p>(Abbildung 1: Unsortierte Basistabelle)</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">
SELECT LEVEL
     , rpad(' ',LEVEL) || label
  FROM menu_tree a
 START WITH a.parent_id IS NULL
       CONNECT BY PRIOR a.id= a.parent_id
 ORDER siblings BY sort
</pre>
</div>
</div>
<p><font face="Courier New"></font></p>
<table border="1" cellspacing="0" cellpadding="2" width="365">
<tbody>
<tr>
<td valign="top" width="59">LEVEL</td>
<td valign="top" width="248">LABEL</td>
<td valign="top" width="56">SORT</td>
</tr>
<tr>
<td valign="top" width="66">1</td>
<td valign="top" width="251">Anwendung</td>
<td valign="top" width="61">1</td>
</tr>
<tr>
<td valign="top" width="70">2</td>
<td valign="top" width="246"> Berichte</td>
<td valign="top" width="65">1</td>
</tr>
<tr>
<td valign="top" width="73">2</td>
<td valign="top" width="241"> Hilfsdaten</td>
<td valign="top" width="68">2</td>
</tr>
<tr>
<td valign="top" width="75">3</td>
<td valign="top" width="238">&#160; Buchungsgründe</td>
<td valign="top" width="70">1</td>
</tr>
<tr>
<td valign="top" width="76">3</td>
<td valign="top" width="236">&#160; Kostenstellen</td>
<td valign="top" width="71">2</td>
</tr>
<tr>
<td valign="top" width="77">3</td>
<td valign="top" width="235">&#160; Währung</td>
<td valign="top" width="71">3</td>
</tr>
<tr>
<td valign="top" width="77">2</td>
<td valign="top" width="235"> System</td>
<td valign="top" width="71">3</td>
</tr>
<tr>
<td valign="top" width="77">3</td>
<td valign="top" width="235">&#160; Anmelden</td>
<td valign="top" width="71">1</td>
</tr>
</tbody>
</table>
<p>(Abbildung 2: Sortiertes Ergebnis)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2010/04/05/sortierung-von-hierachischen-bumen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install postgres 8.4 on Debian 5 (lenny)</title>
		<link>http://www.entwicklungsgedanken.de/2010/03/06/how-to-install-postgres-8-4-on-debian-5-lenny/</link>
		<comments>http://www.entwicklungsgedanken.de/2010/03/06/how-to-install-postgres-8-4-on-debian-5-lenny/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 13:28:23 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[backport]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/?p=385</guid>
		<description><![CDATA[Because I didn&#8217;t found this information in one place I&#8217;m writing this quick &#8220;guide&#8221; on how to install PostgreSQL 8.4.x on Debian 5.x &#8220;lenny&#8221;. Debian lenny stable packages are bundled with Postgres 8.3.x but thanks to Debian Backports the newer Postgres version is available for lenny. Simply do it Add the backports-sources (/etc/apt/sources.list) and update [...]]]></description>
			<content:encoded><![CDATA[<p>Because I didn&#8217;t found this information in one place I&#8217;m writing this quick &#8220;guide&#8221; on how to install <a href="http://www.postgresql.org/docs/8.4/interactive/index.html">PostgreSQL 8.4.x</a> on <a href="http://www.debian.org/">Debian 5.x &#8220;lenny&#8221;</a>.</p>
<p>Debian lenny stable packages are bundled with Postgres 8.3.x but thanks to Debian <a href="http://www.backports.org/dokuwiki/doku.php">Backports</a> the newer Postgres version is available for lenny.</p>
<h3>Simply do it</h3>
<p>Add the backports-sources (/etc/apt/sources.list) and update (apt-get update)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">deb http:<span style="color: #000000; font-weight: bold;">//</span>www.backports.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny-backports main contrib non-free</pre></div></div>

<p>Install postgres</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-t</span> lenny-backports <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql-<span style="color: #000000;">8.4</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2010/03/06/how-to-install-postgres-8-4-on-debian-5-lenny/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Allowing PostgreSQL to use an index when the query uses the LIKE-operator</title>
		<link>http://www.entwicklungsgedanken.de/2009/08/05/allowing-postgresql-to-use-an-index-when-the-query-uses-the-like-operator/</link>
		<comments>http://www.entwicklungsgedanken.de/2009/08/05/allowing-postgresql-to-use-an-index-when-the-query-uses-the-like-operator/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 18:31:14 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[like]]></category>
		<category><![CDATA[operator class]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[wildcard]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/?p=312</guid>
		<description><![CDATA[When enabling search in database its very important to have the appropriate indexes defined to make the queries as fast as possible. If your query looks like this (and the appropriate index is defined) the index can be used by the database (the query planner) even with the LIKE-operator. So fast wildcard-searches are possible &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>When enabling search in database its very important to have the appropriate indexes defined to make the queries as fast as possible. If your query looks like this (and the appropriate index is defined) the index can be used by the database (the query planner) even with the <code>LIKE</code>-operator. So fast wildcard-searches are possible &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> col1 <span style="color: #993333; font-weight: bold;">FROM</span> foobar <span style="color: #993333; font-weight: bold;">WHERE</span> col1 <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'1234%'</span>;</pre></div></div>

<h3>Yes?! Really?!</h3>
<p>In one of our production systems this kind of query (when debugged via <code>EXPLAIN</code> / <code>EXPLAIN ANALYZE</code>) return unexpected results. Every time our comparison operator turns from equality <code>=</code> into <code>LIKE</code> the index for the column is fully ignored and instead a full-table scan (sequential scan) is used by the planner. Things are really slow &#8230;</p>
<h3>I locale you!</h3>
<p>After asking Google its seems some more people having this issue, too.<br />Our database-cluster was initialized with the locale de_DE.utf8. A quick view into the excellent documentation for <code>CREATE INDEX</code> revealed there is an <a href="http://www.postgresql.org/docs/8.3/interactive/indexes-opclass.html">operator class</a> which controls the operators of the index. After adding an index with an operator class for that column the index (&#8220;FoobarWildcardIdx&#8221;) is now used even when the query contains <code>LIKE</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">INDEX</span> FoobarWildcardIdx <span style="color: #993333; font-weight: bold;">ON</span> foobar <span style="color: #66cc66;">&#40;</span>col1 varchar_pattern_ops<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2009/08/05/allowing-postgresql-to-use-an-index-when-the-query-uses-the-like-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installation problems with SQL Server 2008</title>
		<link>http://www.entwicklungsgedanken.de/2009/01/28/installation-problems-with-sql-server-2008/</link>
		<comments>http://www.entwicklungsgedanken.de/2009/01/28/installation-problems-with-sql-server-2008/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 22:49:37 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint-Development]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[MSXML 6.0]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/?p=181</guid>
		<description><![CDATA[Today I decided to upgrade my windows internal database on my &#8220;VMWare-SharePoint-Development-System&#8221;. An upgrade was not possible so I removed the internal database (Microsoft##SSEE) and tried to install the new SQL Server (installation platform is w2k3-server, x86). My development system is a WSS 3.0 SP1 + Visual Studio 2008 environment. Error Clicking through the installation [...]]]></description>
			<content:encoded><![CDATA[<p>Today I decided to upgrade my windows internal database on my &#8220;VMWare-SharePoint-Development-System&#8221;. An upgrade was not possible so I removed the internal database (Microsoft##SSEE) and tried to install the new SQL Server (installation platform is w2k3-server, x86). My development system is a WSS 3.0 SP1 + Visual Studio 2008 environment.</p>
<h3>Error</h3>
<p>Clicking through the installation wizard went fine but then the installation cancelled with &#8220;nice&#8221; red error icons. A look into the logfile showed the following.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Property<span style="color: #7a0874; font-weight: bold;">&#40;</span>S<span style="color: #7a0874; font-weight: bold;">&#41;</span>: ACTION = INSTALL
MSI <span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>08:D0<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">23</span>:01:<span style="color: #000000;">25</span>:<span style="color: #000000;">354</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Note: <span style="color: #000000;">1</span>: <span style="color: #000000;">1708</span>
MSI <span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>08:D0<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">23</span>:01:<span style="color: #000000;">25</span>:<span style="color: #000000;">354</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Produkt: MSXML <span style="color: #000000;">6.0</span> Parser <span style="color: #7a0874; font-weight: bold;">&#40;</span>KB933579<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #660033;">--</span> Die Installation ist fehlgeschlagen.
&nbsp;
MSI <span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>08:D0<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">23</span>:01:<span style="color: #000000;">25</span>:<span style="color: #000000;">354</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Das Produkt wurde durch Windows Installer installiert. Produktname: MSXML <span style="color: #000000;">6.0</span> Parser <span style="color: #7a0874; font-weight: bold;">&#40;</span>KB933579<span style="color: #7a0874; font-weight: bold;">&#41;</span>. Produktversion: 6.10.1200.0. Produktsprache: 1031. Erfolg- bzw. Fehlerstatus der Installation: 1603.
&nbsp;
MSI <span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>08:D0<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">23</span>:01:<span style="color: #000000;">25</span>:<span style="color: #000000;">385</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Cleaning up uninstalled <span style="color: #c20cb9; font-weight: bold;">install</span> packages, <span style="color: #000000; font-weight: bold;">if</span> any exist</pre></div></div>

<p>I downloaded the MSXML 6.0 Parser from the Microsoft Download page and tried to install it. Error! A newer product is already installed. A short look into &#8220;Software Installation&#8221; revealed that I have MSXML Parser 6.0 SP2 installed. Okay looks good for me but not for SQL Server 2008.</p>
<h3>Being up-to-date is not always good</h3>
<p>The installation routine depends on the installation of the MSXML Parser 6.0&#8230; In the end I uninstalled MSXML Parser 6.0 SP2 and started the installation again. Tadaaaa! It works. SQL Server was installed successfully. Now I can &#8220;re-apply&#8221; SP2 for the MSXML Parser 6.0</p>
<h3>Woohoo</h3>
<p>I started the windows <code>command-line</code> and entered <code>date</code>. It showed <code>2009-01-28</code>. As you can see the year is 2009!<br />
Having to do such steps to get an installation of SQL Server 2008 made me think I am in the year 1998! Wtf?!</p>
<p><strong>Update:</strong> A friend of mine had <a href="http://www.coeamyd.net/PermaLink,guid,53accd33-6788-4f91-b847-f316050c0e41.aspx">problems with SQL Server 2008 installation</a>, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2009/01/28/installation-problems-with-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
