<?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/"
	
	>
<channel>
	<title>
	Comments on: Speeding up Matlab-JDBC SQL queries	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=speeding-up-matlab-jdbc-sql-queries</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Fri, 23 Feb 2024 14:02:41 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-523652</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 23 Feb 2024 14:02:41 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-523652</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-523607&quot;&gt;Peter Raahauge&lt;/a&gt;.

@Peter - I&#039;m happy to hear that you found my work useful. Feel free to use my algorithm and code for any non-commercial research usage. I just ask that you add references to undocumentedmatlab.com and my book (&lt;a href=&quot;http://undocumentedmatlab.com/books/matlab-performance&quot; target=&quot;_blank&quot;&gt;Accelerating Matlab Performance&lt;/a&gt;, CRC Press, ISBN 9781482211290) in your published work.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-523607">Peter Raahauge</a>.</p>
<p>@Peter &#8211; I&#8217;m happy to hear that you found my work useful. Feel free to use my algorithm and code for any non-commercial research usage. I just ask that you add references to undocumentedmatlab.com and my book (<a href="http://undocumentedmatlab.com/books/matlab-performance" target="_blank">Accelerating Matlab Performance</a>, CRC Press, ISBN 9781482211290) in your published work.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peter Raahauge		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-523607</link>

		<dc:creator><![CDATA[Peter Raahauge]]></dc:creator>
		<pubDate>Tue, 13 Feb 2024 11:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-523607</guid>

					<description><![CDATA[Hi Yair,
I have a copyright question, and a comment to your statement above: &quot;the speed remains nearly unaffected when you pre-allocate data properly.&quot;
One of my colleges are downloading data from Wharton Research Data Service (WRDS) for his research in Matlab.
WRDS are providing a guide for Matlab-users, and it basically includes an algorithm like the first one presented above for getting the data into Matlab&#039;s memory.
The SQL-tables he&#039;s downloading typically have 3 million rows but very few variables.  
Initially, he was complaining about the WRDS-solution, as a query like the one above took 2-3 hours. However, once he got the data variable pre-allocated appropriately, the query was done in 5 minutes. That&#039;s actually a factor 30(!)
With your Java-code, we can get the time down even more with something similar to the factor 15 you mention above.
This leads me to the copyright question: How should I deal with the copyright? We are only using your algorithm for research purposes and nothing commercial.]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,<br />
I have a copyright question, and a comment to your statement above: &#8220;the speed remains nearly unaffected when you pre-allocate data properly.&#8221;<br />
One of my colleges are downloading data from Wharton Research Data Service (WRDS) for his research in Matlab.<br />
WRDS are providing a guide for Matlab-users, and it basically includes an algorithm like the first one presented above for getting the data into Matlab&#8217;s memory.<br />
The SQL-tables he&#8217;s downloading typically have 3 million rows but very few variables.<br />
Initially, he was complaining about the WRDS-solution, as a query like the one above took 2-3 hours. However, once he got the data variable pre-allocated appropriately, the query was done in 5 minutes. That&#8217;s actually a factor 30(!)<br />
With your Java-code, we can get the time down even more with something similar to the factor 15 you mention above.<br />
This leads me to the copyright question: How should I deal with the copyright? We are only using your algorithm for research purposes and nothing commercial.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jeremy		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-499395</link>

		<dc:creator><![CDATA[Jeremy]]></dc:creator>
		<pubDate>Mon, 23 Sep 2019 16:57:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-499395</guid>

					<description><![CDATA[Yair,  

Thank you for your work, most likely buying the book soon. But in the meantime I&#039;m hitting a snag on setting up the JDBC connection on the fly.  Can you provide a bit more explanation and or hints on the steps required?  I can use database toolbox to do the setup and it works just fine, but I would rather be able to hardcode it so that my application/code is portable.]]></description>
			<content:encoded><![CDATA[<p>Yair,  </p>
<p>Thank you for your work, most likely buying the book soon. But in the meantime I&#8217;m hitting a snag on setting up the JDBC connection on the fly.  Can you provide a bit more explanation and or hints on the steps required?  I can use database toolbox to do the setup and it works just fine, but I would rather be able to hardcode it so that my application/code is portable.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Paul		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-406321</link>

		<dc:creator><![CDATA[Paul]]></dc:creator>
		<pubDate>Mon, 08 May 2017 23:19:17 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-406321</guid>

					<description><![CDATA[Hey there,

just wanted to say thank you for this page. I found a lot of valuable information here how to handle result sets from java in matlab.

Best Regards
Paul]]></description>
			<content:encoded><![CDATA[<p>Hey there,</p>
<p>just wanted to say thank you for this page. I found a lot of valuable information here how to handle result sets from java in matlab.</p>
<p>Best Regards<br />
Paul</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393990</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 22 Nov 2016 06:43:30 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-393990</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393924&quot;&gt;virns&lt;/a&gt;.

Try to close the &lt;code&gt;ResultSet&lt;/code&gt; and &lt;code&gt;stmt&lt;/code&gt; (as I&#039;ve shown in the post) after you&#039;ve used them, in order to clear the cache between subsequent JDBC calls, otherwise they might remain in memory and cause an eventual heap-memory error.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393924">virns</a>.</p>
<p>Try to close the <code>ResultSet</code> and <code>stmt</code> (as I&#8217;ve shown in the post) after you&#8217;ve used them, in order to clear the cache between subsequent JDBC calls, otherwise they might remain in memory and cause an eventual heap-memory error.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393949</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Mon, 21 Nov 2016 16:57:25 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-393949</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393916&quot;&gt;aviolov&lt;/a&gt;.

I do not believe that JDBC has such an easy-to-use wrapper, unfortunately.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393916">aviolov</a>.</p>
<p>I do not believe that JDBC has such an easy-to-use wrapper, unfortunately.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Oleg		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393948</link>

		<dc:creator><![CDATA[Oleg]]></dc:creator>
		<pubDate>Mon, 21 Nov 2016 16:46:37 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-393948</guid>

					<description><![CDATA[I faced this issue with the Matlab Database Toolbox and tackled it by: 
* setting the &lt;i&gt;&#039;DataReturnFormat&#039;&lt;/i&gt; to &lt;i&gt;&#039;numeric&#039;&lt;/i&gt;;
* querying results by column and converting the numeric stream into its column format]]></description>
			<content:encoded><![CDATA[<p>I faced this issue with the Matlab Database Toolbox and tackled it by:<br />
* setting the <i>&#8216;DataReturnFormat&#8217;</i> to <i>&#8216;numeric&#8217;</i>;<br />
* querying results by column and converting the numeric stream into its column format</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: virns		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393924</link>

		<dc:creator><![CDATA[virns]]></dc:creator>
		<pubDate>Mon, 21 Nov 2016 10:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-393924</guid>

					<description><![CDATA[Hi
Please help me get rid of &quot;jave heap memory error&quot; in standalone executable (tried both windows and linux versions). I am creating a SQL connection (using JDBC) outside the infinity while loop and then checking with &quot;isopen or isconnection&quot; inside the loop. I read in some forum that the SQL JDBC driver caches the queries which could be the cause. I&#039;ve also tried deleting unused variables in the loop but it didn&#039;t help.

Thanks]]></description>
			<content:encoded><![CDATA[<p>Hi<br />
Please help me get rid of &#8220;jave heap memory error&#8221; in standalone executable (tried both windows and linux versions). I am creating a SQL connection (using JDBC) outside the infinity while loop and then checking with &#8220;isopen or isconnection&#8221; inside the loop. I read in some forum that the SQL JDBC driver caches the queries which could be the cause. I&#8217;ve also tried deleting unused variables in the loop but it didn&#8217;t help.</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: aviolov		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-matlab-jdbc-sql-queries#comment-393916</link>

		<dc:creator><![CDATA[aviolov]]></dc:creator>
		<pubDate>Mon, 21 Nov 2016 08:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6742#comment-393916</guid>

					<description><![CDATA[Cool,

We do a similar thing using C# and DataTable

&lt;pre lang=&quot;matlab&quot;&gt;
import System.Data.DataTable
import System.Data.SqlClient.*
sqlConn = SqlConnection(...);
sqlCmd = SqlCommand(sql_query_string, sqlConn);
sqlAdaptor = SqlDataAdapter(sqlCmd);
dataTable = DataTable();
sqlConn.Open();
sqlAdaptor.Fill(dataTable);
T = dataTable2matlabTable(dataTable); % This does the same column based-fill as in your code.
...
&lt;/pre&gt;

So I&#039;m wondering is it really necessary to make the specific class (JDBC_Fetch.java) to iterate the rows of a ResultSet or does Java not have an equivalent to C#&#039;s DataTable that kind of does that for you, i.e. a data-struct that returns columns instead of rows, roughly speaking, and you can already work on its columns instead of calling rs.next() in an extra for loop? Or maybe the equivalent does not give the necessary speed-up?

best,]]></description>
			<content:encoded><![CDATA[<p>Cool,</p>
<p>We do a similar thing using C# and DataTable</p>
<pre lang="matlab">
import System.Data.DataTable
import System.Data.SqlClient.*
sqlConn = SqlConnection(...);
sqlCmd = SqlCommand(sql_query_string, sqlConn);
sqlAdaptor = SqlDataAdapter(sqlCmd);
dataTable = DataTable();
sqlConn.Open();
sqlAdaptor.Fill(dataTable);
T = dataTable2matlabTable(dataTable); % This does the same column based-fill as in your code.
...
</pre>
<p>So I&#8217;m wondering is it really necessary to make the specific class (JDBC_Fetch.java) to iterate the rows of a ResultSet or does Java not have an equivalent to C#&#8217;s DataTable that kind of does that for you, i.e. a data-struct that returns columns instead of rows, roughly speaking, and you can already work on its columns instead of calling rs.next() in an extra for loop? Or maybe the equivalent does not give the necessary speed-up?</p>
<p>best,</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
