<?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>daydreaming &#187; dev</title>
	<atom:link href="http://n79.org/category/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://n79.org</link>
	<description></description>
	<lastBuildDate>Wed, 18 Jan 2012 06:13:34 +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>Overrides in Camping</title>
		<link>http://n79.org/2008/03/05/overrides-in-camping/</link>
		<comments>http://n79.org/2008/03/05/overrides-in-camping/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 08:18:06 +0000</pubDate>
		<dc:creator>nikhilb</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://n79.org/2008/03/05/overrides-in-camping/</guid>
		<description><![CDATA[If you want to add a call to all the controllers in your Camping miroframework app you can use before or after overrides. These are similar to the before_filter in Rails. Remember to return the superclass or Camping will throw a &#8220;Read error: #&#60;NoMethodError: undefined method `status&#8217; for nil:NilClass&#62;&#8221; because it can&#8217;t call back into [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to add a call to all the controllers in your  <a href="http://code.whytheluckystiff.net/camping/" title="Camping Microframework" target="_blank">Camping miroframework</a> app you can use <a href="http://code.whytheluckystiff.net/camping/wiki/BeforeAndAfterOverrides" title="Before or After Override for camping" target="_blank">before or after overrides</a>. These are similar to the <em>before_filter</em> in Rails.</p>
<p>Remember to return the superclass or Camping will throw a <em>&#8220;Read error: #&lt;NoMethodError: undefined method `status&#8217; for nil:NilClass&gt;</em>&#8221; because it can&#8217;t call back into the returned controller. A <font color="#ff0000">modification</font> of the above linked wiki page example illustrates -</p>
<pre class="brush: ruby; title: ; notranslate">
Camping.goes :YourApp

module YourSession
  def service(*a)
    @session = YourApp::Session.new
    s = super(*a)
    @session.close
    #return s from above after completing
    s
  end
end

module YourApp
  include YourSession
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://n79.org/2008/03/05/overrides-in-camping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing an SQL LIKE Query</title>
		<link>http://n79.org/2006/03/07/optimizing-an-sql-like-query/</link>
		<comments>http://n79.org/2006/03/07/optimizing-an-sql-like-query/#comments</comments>
		<pubDate>Wed, 08 Mar 2006 03:58:20 +0000</pubDate>
		<dc:creator>nikhilb</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://thoughts.n79.org/2006/03/07/optimizing-an-sql-like-query/</guid>
		<description><![CDATA[Carlos did a quick test earlier in the day on our Apache Derby backend and found that in a particular like query Derby was 23x slower than on a equality query over the same data set. Very often, databases do not optimize LIKE queries, partially because it is rare for them to support the types [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Carlos Maltzahn" href="http://www.soe.ucsc.edu/~carlosm/">Carlos</a> did a quick test earlier in the day on our <a title="Apache Derby" href="http://db.apache.org/derby/">Apache Derby</a> backend and found that in a particular like query Derby was 23x slower than on a equality query over the same data set. Very often, databases do not optimize LIKE queries, partially because it is rare for them to support the types of indices such optimizations would require.</p>
<p>It took me a little while to find this <a target="_blank" title="Apache Derby LIKE Transformations" href="http://db.apache.org/derby/docs/10.0/manuals/tuning/perf96.html#HDRSII-TRANSFORM-37208">gem on LIKE Transformations  </a>in the Derby tuning manual. Basically the document covers some transformations which the Derby SQL parser goes through to make LIKE queries optimizable. For me, this solved the problem as it allowed me to rewrite my query into a form that was optimizable albeit with a slight loss of functionality in my application. Unfortunately, this is not the case for all LIKE queries. The transformations are quite obvious and easy to follow once you see them, so take a look if you are having similar performance problems.</p>
<blockquote><p><strong>Before:</strong></p>
<blockquote><p>SELECT checksum FROM tags WHERE tag LIKE &#8216;%element%&#8217;</p>
<p><strong>Gets parsed into &#8211;</strong>  SELECT checksum FROM tags WHERE tag LIKE &#8216;%element%&#8217;</p></blockquote>
<p><strong>After</strong></p>
<blockquote><p>SELECT checksum FROM tags WHERE tag LIKE &#8216;element%&#8217;</p>
<p><strong>Gets parsed into &#8211;</strong>  SELECT checksum FROM tags WHERE tag >= &#8216;element&#8217;   AND tag < 'elemenu'</p></blockquote>
</blockquote>
<p>These transformations are also potentially useful with databases other than Derby when LIKE queries are running slow, as you could do them manually on your statements to the fullest extent possible potentially eliminating LIKE altogether.</p>
]]></content:encoded>
			<wfw:commentRss>http://n79.org/2006/03/07/optimizing-an-sql-like-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.436 seconds -->

