How to make faster sql queries

조회 수: 2 (최근 30일)
012786534
012786534 2019년 9월 18일
댓글: Klemen Peter Kosovinc 2020년 10월 21일
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
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 CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by