speed up database query

4 ビュー (過去 30 日間)
HILTON MARQUES SANTANA
HILTON MARQUES SANTANA 2022 年 7 月 18 日
回答済み: Abhijeet 2023 年 9 月 5 日
Hello guys, I am trying to speed up database query using the parallel computing toolbox. I have already tried two ways:
c = createConnectionForPool(gcp(), 'short_term_memory',"root","1234");
1)
f1 = parfeval(@(c,varargin) fetch(c.Value, varargin{:}),1,c,query1);
f2 = parfeval(@(c,varargin) fetch(c.Value, varargin{:}),1,c,query2);
f3 = parfeval(@(c,varargin) fetch(c.Value, varargin{:}),1,c,query3);
res1 = fetchOutputs(f1);
res2 = fetchOutputs(f2);
res3 = fetchOutputs(f3);
2)
queries = [query1,query2,query3];
parfor i = 1:length(queries)
conn = c.Value;
results = fetch(conn,queries(i));
res{i} = results
end
But neither of the two ways really reduces the total query time. What else I could do?

回答 (1 件)

Abhijeet
Abhijeet 2023 年 9 月 5 日
Hi Hilton,
I can understand that you want to speed up database query.To resolve the issue, I can suggest the following alternatives :-
  • You can club all three queries into a SQL script and use the ‘executeSQLScript function. In this way there is no need to call multiple fetch () calls.
  • If you are using relational database, then make sure you have used suitable indexing.
  • For speed up you can try switching to columnar database if queries are related to analytics or to NoSQL database if your database is unstructured.
For more information about executeSQLScript refer to the following documentation
For more information about Columnar and NoSQL database refer to the following documentation
I hope this information was helpful!

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by