[ MATLAB + SQL Server ] Slow performance when fetching data
Afficher commentaires plus anciens
Hi all
I have a problem fetching data from a SQL database. I have tried using JDBC 4.0 and, as illustrated below, the .NET way.
import System.Data.SqlClient.*
NET.addAssembly('System.Data');
conn = SqlConnection('Data Source=myServer;Initial Catalog=myDatabase;Integrated Security=true');
conn.Open();
q = SqlCommand('select top 10000 myNumber from myTable', conn);
r = q.ExecuteReader();
data = zeros(1,10000);
tic
while r.Read()
r.GetFloat(0);
end
toc
r.Close()
conn.Close()
My problem is that the while-loop performs quite slowly. It takes up to 8-10 seconds to fetch the data.
One might ask why I think this is slow, but if I perform the very same query through SQL Management Studio it takes 0.01 seconds to fetch and present the 10000 rows.
So my question is: Why is MATLAB so much slower in fetching 10000 rows? It's obviously not the database or the LAN-connection which performs badly.
1 commentaire
Réponses (0)
Catégories
En savoir plus sur Database Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!