<?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; case-insensitive</title>
	<atom:link href="http://www.entwicklungsgedanken.de/tag/case-insensitive/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.entwicklungsgedanken.de</link>
	<description>Verschiedene Gedanken rund um die Softwareentwicklung</description>
	<lastBuildDate>Mon, 09 Jan 2012 14:47:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Performance increase when using case-insensitive queries with Symfony, Propel and PostgreSQL</title>
		<link>http://www.entwicklungsgedanken.de/2008/01/24/performance-increase-when-using-case-insensitive-queries-with-symfony-propel-and-postgresql/</link>
		<comments>http://www.entwicklungsgedanken.de/2008/01/24/performance-increase-when-using-case-insensitive-queries-with-symfony-propel-and-postgresql/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 10:39:25 +0000</pubDate>
		<dc:creator>Eric Bartels</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[case-insensitive]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[propel]]></category>

		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/01/24/performance-increase-when-using-case-insensitive-queries-with-symfony-propel-and-postgresql/</guid>
		<description><![CDATA[Symfony makes heavy use of Propel. Propel finds objects in the storage container using criteria. If you want to let Propel (okay the database) ignore the case you can set this in the criteria. $c = new Criteria &#40;&#41;; &#160; // Allow case sensitive searches $c-&#62;setIgnoreCase &#40;true&#41;; &#160; // Find all posts which name contains [...]]]></description>
			<content:encoded><![CDATA[<div class="lang-en"></div>
<p><a href="http://www.symfony-project.org/" class="external">Symfony</a> makes heavy use of <a href="http://propel.phpdb.org/trac/" class="external">Propel</a>. Propel finds objects in the storage container using criteria. If you want to let Propel (okay the database) ignore the case you can set this in the criteria.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Criteria <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Allow case sensitive searches</span>
<span style="color: #000088;">$c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIgnoreCase</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Find all posts which name contains propel</span>
<span style="color: #000088;">$c</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span> <span style="color: #009900;">&#40;</span>BlogPostPeer<span style="color: #339933;">::</span><span style="color: #004000;">NAME</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Propel'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> BlogPostPeer<span style="color: #339933;">::</span><span style="color: #004000;">doSelect</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Because PostgreSQL (unlike MySQL) does not support collations to easily manage how comparisons of strings are done Propel has to generate this sql-statement.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> blog_posts<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> blog_posts<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">DATE</span>
<span style="color: #993333; font-weight: bold;">FROM</span> blog_posts
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">UPPER</span><span style="color: #66cc66;">&#40;</span>blog_posts<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'PROPEL'</span>;</pre></div></div>

<p>Depending on your amount of data this can become <strong>very slow</strong> even if you have an index defined for the &quot;name&quot;-column.</p>
<p>
The trick is to create <em>another index</em> for the column &quot;name&quot;.
</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> <span style="color: #ff0000;">&quot;UpperNameIndex&quot;</span> <span style="color: #993333; font-weight: bold;">ON</span> blog_posts <span style="color: #993333; font-weight: bold;">USING</span> BTREE <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">UPPER</span><span style="color: #66cc66;">&#40;</span>name<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Thats it. When now using <code>setIgnoreCase</code> its fast again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklungsgedanken.de/2008/01/24/performance-increase-when-using-case-insensitive-queries-with-symfony-propel-and-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

