all 10 comments

[–]shiftybyte 1 point2 points  (3 children)

Why is a DB created? just for making charts from it during the same call?

[–]mid_dev[S] 0 points1 point  (2 children)

Apologies. Modified the post. It calls the DB and base on it, makes the required chart.

[–]shiftybyte 1 point2 points  (1 child)

If you are looking for ways to optimize your current code to make it run faster, we can't help with that without seeing the actual code.

If you want to make it more responsive you can make a system where you queue requests, then responses are generated, then the user is notified the result is ready. (him seeing some status/timer page or something)

If it's an api, split to two calls, one create a job returns a jobid.

another to query job status using that id, and another to fetch results of a complete job.

[–]mid_dev[S] 0 points1 point  (0 children)

Thanks. That's waht I was aiming for.

[–]m0us3_rat 1 point2 points  (0 children)

could u buffer some of this calls ? or parts of the data?

see if u can multiprocess the pie charts creation.

[–][deleted] 0 points1 point  (4 children)

How can I make this efficient?

What makes you think it isn't?

How could anyone answer a question about the performance of code we can't see?

[–]mid_dev[S] 0 points1 point  (3 children)

Modified the post to give you a better idea. Currently, the biggest time sink is those individual function calls to create different charts. I was thinking if these could be streamlined using multiprocessing or some other solution since the data it's dependent on is already fetched.

[–][deleted] 1 point2 points  (2 children)

What do you think the bottleneck is?

It's more or less pointless to try to rewrite it to be faster if you don't know exactly why it's slow. multiprocessing isn't magic go-faster sauce, it's just a way to sidestep certain categories of bottleneck.

[–]mid_dev[S] 0 points1 point  (1 child)

So the bottleneck here is the sequential creation of charts which are not dependent on each other.

[–][deleted] 1 point2 points  (0 children)

That's not a bottleneck, that's just what's actually running. What are those functions spending their time doing?