<!-- 
RSS generated by JIRA (4.4#649-r158309) at Sat May 25 19:08:11 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/CONTRIB-88/CONTRIB-88.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[CONTRIB-88] clojure.contrib.sql runs out of memory on very large datasets</title>
                <link>http://dev.clojure.org/jira/browse/CONTRIB-88</link>
                <project id="10012" key="CONTRIB">Clojure-Contrib</project>
                        <description>&lt;p&gt;If you have a query that results in a very large dataset you will run out of memory because by  default, with-query-results pulls the entire result set into memory (even though it creates a lazy-seq using resultset-seq). &lt;/p&gt;

&lt;p&gt;This issue has been discussed previously here: &lt;br/&gt;
  &lt;a href=&quot;http://groups.google.com/group/clojure/browse_thread/thread/7b0c250e0ba6c9eb/fb9001522b49c20a&quot;&gt;http://groups.google.com/group/clojure/browse_thread/thread/7b0c250e0ba6c9eb/fb9001522b49c20a&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix is simple, just call (.setFetchSize stmt 1). But, with-query-results doesn&apos;t give you a way to do that currently. I propose adding an optional parameter after sql-params that is a hash of attributes to set on the PreparedStatement before executing it.&lt;/p&gt;

&lt;p&gt;So you can do this: &lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;(with-connection {&#65533;&#65533;&#65533;} 
    (.setAutoCommit (sql/connection) &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) ;; needed &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; postgres 
    (with-query-results results [&lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT id, data FROM nodes&quot;&lt;/span&gt;] 
      {:fetch-size 1000} 
      (doseq [r results] 
        &#65533;&#65533;&#65533;)))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;The new code in clojure.contrib.sql is very simple, but it depends on a new contrib namespace called clojure.contrib.bean. Here is more info on my proposed fix:&lt;br/&gt;
  &lt;a href=&quot;http://groups.google.com/group/clojure-dev/browse_thread/thread/d8334759f10f3f45&quot;&gt;http://groups.google.com/group/clojure-dev/browse_thread/thread/d8334759f10f3f45&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
            <key id="14248">CONTRIB-88</key>
            <summary>clojure.contrib.sql runs out of memory on very large datasets</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                        <status id="3" iconUrl="http://dev.clojure.org/jira/images/icons/status_inprogress.gif">In Progress</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="importer">Assembla Importer</assignee>
                                <reporter username="-1">None</reporter>
                        <labels>
                    </labels>
                <created>Fri, 9 Jul 2010 21:12:00 -0500</created>
                <updated>Tue, 24 Aug 2010 20:09:00 -0500</updated>
                                                                            <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="25829" author="importer" created="Tue, 24 Aug 2010 20:09:00 -0500"  >&lt;p&gt;Converted from &lt;a href=&quot;http://www.assembla.com/spaces/clojure/tickets/88&quot;&gt;http://www.assembla.com/spaces/clojure/tickets/88&lt;/a&gt;&lt;br/&gt;
Attachments:&lt;br/&gt;
sql-stmt-opts-with-bean.diff - &lt;a href=&quot;https://www.assembla.com/spaces/clojure/documents/cjDxceI4er36sweJe5cbCb/download/cjDxceI4er36sweJe5cbCb&quot;&gt;https://www.assembla.com/spaces/clojure/documents/cjDxceI4er36sweJe5cbCb/download/cjDxceI4er36sweJe5cbCb&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="25830" author="importer" created="Tue, 24 Aug 2010 20:09:00 -0500"  >&lt;p&gt;importer said: [&lt;a href=&quot;file:cFaBqYI38r3565eJe5cbLA&quot;&gt;file:cFaBqYI38r3565eJe5cbLA&lt;/a&gt;]&lt;/p&gt;</comment>
                    <comment id="25831" author="importer" created="Tue, 24 Aug 2010 20:09:00 -0500"  >&lt;p&gt;importer said: [&lt;a href=&quot;file:cjDxceI4er36sweJe5cbCb&quot;&gt;file:cjDxceI4er36sweJe5cbCb&lt;/a&gt;]&lt;/p&gt;</comment>
                    <comment id="25832" author="importer" created="Tue, 24 Aug 2010 20:09:00 -0500"  >&lt;p&gt;importer said: Hey Steve,&lt;/p&gt;

&lt;p&gt;Any progress on this? Another option instead of passing a map of attributes and using bean would be to allow the user to pass an optional function that would be called on the statement object. I&apos;ve seen code like this in compojure, I think:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;(with-connection {&#65533;&#65533;&#65533;} 
    (.setAutoCommit (sql/connection) &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;) ;; needed &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; postgres 
    (with-query-results results [&lt;span class=&quot;code-quote&quot;&gt;&quot;SELECT id, data FROM nodes&quot;&lt;/span&gt;] 
      #(.setFetchSize % 1) 
      (doseq [r results] 
        &#65533;&#65533;&#65533;)))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If this sounds better to you, I can submit a patch.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Justin&lt;/p&gt;</comment>
                    <comment id="25833" author="importer" created="Tue, 24 Aug 2010 20:09:00 -0500"  >&lt;p&gt;importer said: Kyle Burton just posted a blog post about this issue: &lt;a href=&quot;http://asymmetrical-view.com/2010/10/14/clojure-lazy-walk-sql-table.html&quot;&gt;http://asymmetrical-view.com/2010/10/14/clojure-lazy-walk-sql-table.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;His fix is to add a new method called with-query-results-cursor which turns off auto-commit and sets the fetch size.&lt;/p&gt;

&lt;p&gt;Steve, would this approach work better for you?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                                                                                            </customfields>
    </item>
</channel>
</rss>