How to make faster sql queries
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I am struggling to make SQL queries faster in Matlab. For example, the SQL query below contains not quite 500 000 rows and takes 250 seconds to fetch in Matlab but takes only 15 seconds in R. This is problematic particularly for large queries that can include as much as 7 millions rows. So how does one make SQL queries faster ? I have tried to increase the batch size but it doesnt really make a difference.
% Pass user and password info for connection to database
conn = database('NFG', input{1,1}, input{2,1});
tic;
% Query data
sqlquery = ['SELECT mi.desc_miss, ', ...
'xbt.latd lat, ', ...
'xbt.lond lon, ', ...
'to_char(xbt.sytm, ''YYYY'') as year, ', ...
'to_char(xbt.sytm, ''MM'') as month, ', ...
'xbt.deph, ', ...
'xbt.te90 temp ', ...
'FROM NFG.MISSION_EXP mi, NFG.JEU_DONNEES jd, NFG.DONNEES_XBT xbt ', ...
'WHERE xbt.SEQ_JD = jd.seq_jd ', ...
'AND mi.acr_miss = jd.acr_miss '];
xbt_data = fetch(conn, sqlquery, 100000);
toc;
댓글 수: 1
Klemen Peter Kosovinc
2020년 10월 21일
Hello!
Did you find any solution to the problem?
Did you manage to speed up the queries?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!