<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: MySQL JDBC Memory Usage on Large ResultSet</title>
	<atom:link href="http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/feed/" rel="self" type="application/rss+xml" />
	<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/</link>
	<description></description>
	<lastBuildDate>Fri, 25 May 2012 19:08:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Cory</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-575</link>
		<dc:creator><![CDATA[Cory]]></dc:creator>
		<pubDate>Fri, 25 May 2012 19:08:30 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-575</guid>
		<description><![CDATA[Thank you! This was very helpful. =D]]></description>
		<content:encoded><![CDATA[<p>Thank you! This was very helpful. =D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sardar Faisal</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-534</link>
		<dc:creator><![CDATA[Sardar Faisal]]></dc:creator>
		<pubDate>Tue, 15 Nov 2011 10:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-534</guid>
		<description><![CDATA[I got the answer. I am doing the same as umer. Getting the resultset from this functions and copying it to another resultSet in the calling program. 

Thank you.]]></description>
		<content:encoded><![CDATA[<p>I got the answer. I am doing the same as umer. Getting the resultset from this functions and copying it to another resultSet in the calling program. </p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sardar Faisal</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-533</link>
		<dc:creator><![CDATA[Sardar Faisal]]></dc:creator>
		<pubDate>Tue, 15 Nov 2011 09:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-533</guid>
		<description><![CDATA[Hello Ben,

Here is my code and the same out of memory exception.

public synchronized ResultSet executeSQL(String sql) throws DataAdapterException
    {
ResultSet result = null;
Statement st = _conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
                        java.sql.ResultSet.CONCUR_READ_ONLY);
                st.setFetchSize(Integer.MIN_VALUE);            
                setCurrentStatement(st);
                st.execute(sql);
                result = st.getResultSet();
                if ( result == null )
                    st.close();
            }
            catch ( OutOfMemoryError e )
            {
                MessageLog.errorMessage(&quot;execute method, out of memory exception &quot; + e.getMessage());
            }
finally
            {
                releaseCurrentStatement();
            }
 return result;
    }

java.lang.OutOfMemoryError: Java heap space

then the program crashes. Its ok if it gives the out of memory but should not crash. Thank you]]></description>
		<content:encoded><![CDATA[<p>Hello Ben,</p>
<p>Here is my code and the same out of memory exception.</p>
<p>public synchronized ResultSet executeSQL(String sql) throws DataAdapterException<br />
    {<br />
ResultSet result = null;<br />
Statement st = _conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,<br />
                        java.sql.ResultSet.CONCUR_READ_ONLY);<br />
                st.setFetchSize(Integer.MIN_VALUE);<br />
                setCurrentStatement(st);<br />
                st.execute(sql);<br />
                result = st.getResultSet();<br />
                if ( result == null )<br />
                    st.close();<br />
            }<br />
            catch ( OutOfMemoryError e )<br />
            {<br />
                MessageLog.errorMessage(&#8220;execute method, out of memory exception &#8221; + e.getMessage());<br />
            }<br />
finally<br />
            {<br />
                releaseCurrentStatement();<br />
            }<br />
 return result;<br />
    }</p>
<p>java.lang.OutOfMemoryError: Java heap space</p>
<p>then the program crashes. Its ok if it gives the out of memory but should not crash. Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Per Lindberg</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-525</link>
		<dc:creator><![CDATA[Per Lindberg]]></dc:creator>
		<pubDate>Wed, 28 Sep 2011 07:38:42 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-525</guid>
		<description><![CDATA[Right, it&#039;s clearly not possible to simultanously do other SQL operations on the Connection as the streaming query. That makes sense.

It&#039;s also clear that starting a streaming query puts a lock on the whole table. So trying another SQL operation (e.g. an UPDATE) on the same table using a different Connection won&#039;t work.

I don&#039;t know if this can be worked around by setting some fancy transaction isolation levels. Probably not.

My solution is to put all updated records in a temporary table, and do the real updates afterwards.

Hope this helps others in the same predicament. Cheers!]]></description>
		<content:encoded><![CDATA[<p>Right, it&#8217;s clearly not possible to simultanously do other SQL operations on the Connection as the streaming query. That makes sense.</p>
<p>It&#8217;s also clear that starting a streaming query puts a lock on the whole table. So trying another SQL operation (e.g. an UPDATE) on the same table using a different Connection won&#8217;t work.</p>
<p>I don&#8217;t know if this can be worked around by setting some fancy transaction isolation levels. Probably not.</p>
<p>My solution is to put all updated records in a temporary table, and do the real updates afterwards.</p>
<p>Hope this helps others in the same predicament. Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Christensen</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-524</link>
		<dc:creator><![CDATA[Ben Christensen]]></dc:creator>
		<pubDate>Tue, 27 Sep 2011 16:39:50 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-524</guid>
		<description><![CDATA[I am not actively using MySQL these days so am not setup to test this and don&#039;t know the specific answer.

The documentation talks about concurrent access (see the bottom of the original post) and discusses transactions, etc.

It definitely is not possible to use the same connection as is performing the streaming to do updates, the documentation makes that clear.

What&#039;s not clear to me is whether it is possible to have a second connection also reading and/or writing to the table while another connection is streaming. I haven&#039;t tried that.

I would have to explore further documentation and do a variety of tests with different transaction settings and multiple connections to determine the actual behavior.

If you find this out it would be great if you could report back with that information.]]></description>
		<content:encoded><![CDATA[<p>I am not actively using MySQL these days so am not setup to test this and don&#8217;t know the specific answer.</p>
<p>The documentation talks about concurrent access (see the bottom of the original post) and discusses transactions, etc.</p>
<p>It definitely is not possible to use the same connection as is performing the streaming to do updates, the documentation makes that clear.</p>
<p>What&#8217;s not clear to me is whether it is possible to have a second connection also reading and/or writing to the table while another connection is streaming. I haven&#8217;t tried that.</p>
<p>I would have to explore further documentation and do a variety of tests with different transaction settings and multiple connections to determine the actual behavior.</p>
<p>If you find this out it would be great if you could report back with that information.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Per Lindberg</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-523</link>
		<dc:creator><![CDATA[Per Lindberg]]></dc:creator>
		<pubDate>Mon, 26 Sep 2011 10:20:28 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-523</guid>
		<description><![CDATA[Just a short note to say that the &quot;streaming&quot; hack really works. Thanks again!

Now I have another problem (in a different application): reading a table using the streaming style locks the entire table. So It seems to be impossible to do updates on some of the read records on the fly. Perhaps I have to put them away somewhere during the read phase. Unless there&#039;s some trick you can do by setting some additional transaction isolation parameters...?

(Did I understand that stmt.setFetchSize(10000) is not a practical option since the server would first have to read all the millions of records anyway, before dishing out the result in chunks?)]]></description>
		<content:encoded><![CDATA[<p>Just a short note to say that the &#8220;streaming&#8221; hack really works. Thanks again!</p>
<p>Now I have another problem (in a different application): reading a table using the streaming style locks the entire table. So It seems to be impossible to do updates on some of the read records on the fly. Perhaps I have to put them away somewhere during the read phase. Unless there&#8217;s some trick you can do by setting some additional transaction isolation parameters&#8230;?</p>
<p>(Did I understand that stmt.setFetchSize(10000) is not a practical option since the server would first have to read all the millions of records anyway, before dishing out the result in chunks?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Per Lindberg</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-522</link>
		<dc:creator><![CDATA[Per Lindberg]]></dc:creator>
		<pubDate>Thu, 22 Sep 2011 09:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-522</guid>
		<description><![CDATA[Ben, you rock! All I could add is that the JDBC API should have some more easy-to-understand method to set the streaming mode. Even better, it should be done automagically.]]></description>
		<content:encoded><![CDATA[<p>Ben, you rock! All I could add is that the JDBC API should have some more easy-to-understand method to set the streaming mode. Even better, it should be done automagically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikita Tovstoles</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-498</link>
		<dc:creator><![CDATA[Nikita Tovstoles]]></dc:creator>
		<pubDate>Thu, 23 Jun 2011 00:22:04 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-498</guid>
		<description><![CDATA[Would setting fetch size to something bigger than 1 still work (and prevent the driver from accumulating the entire RS in memory)? Ie can I set fetchSize to, say, 100 rows (and still get server-side cursor)?]]></description>
		<content:encoded><![CDATA[<p>Would setting fetch size to something bigger than 1 still work (and prevent the driver from accumulating the entire RS in memory)? Ie can I set fetchSize to, say, 100 rows (and still get server-side cursor)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morey</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-464</link>
		<dc:creator><![CDATA[Morey]]></dc:creator>
		<pubDate>Wed, 08 Dec 2010 06:56:28 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-464</guid>
		<description><![CDATA[Thanks....this really helped me out!]]></description>
		<content:encoded><![CDATA[<p>Thanks&#8230;.this really helped me out!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Große (riesige!) ResultSets und MySQL &#171; msaure.com</title>
		<link>http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/#comment-396</link>
		<dc:creator><![CDATA[Große (riesige!) ResultSets und MySQL &#171; msaure.com]]></dc:creator>
		<pubDate>Tue, 23 Feb 2010 15:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://benjchristensen.wordpress.com/?p=59#comment-396</guid>
		<description><![CDATA[[...] http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/ wird eine einfache Lösung angeboten, die im Wesentlichen zu folgender Codezeile [...]]]></description>
		<content:encoded><![CDATA[<p>[...] <a href="http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/" rel="nofollow">http://benjchristensen.com/2008/05/27/mysql-jdbc-memory-usage-on-large-resultset/</a> wird eine einfache Lösung angeboten, die im Wesentlichen zu folgender Codezeile [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

