speed up database query

7 Ansichten (letzte 30 Tage)
HILTON MARQUES SANTANA
HILTON MARQUES SANTANA am 18 Jul. 2022
Beantwortet: Abhijeet am 5 Sep. 2023
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?

Antworten (1)

Abhijeet
Abhijeet am 5 Sep. 2023
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!

Community Treasure Hunt

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

Start Hunting!

Translated by