speed up database query

7 次查看(过去 30 天)
HILTON MARQUES SANTANA
回答: 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 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