Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Asset Depreciations and Balances report #18455

Open
wants to merge 16 commits into
base: version-11-hotfix
from

Conversation

@Don-Leopardo
Copy link
Contributor

Don-Leopardo commented Jul 23, 2019

The issue:

This report took ~5 min to be generated and the server was unresponsive in the meantime.

The filters:

Every category in the last year.

The data:

~1400 assets distributed among 76 assets categories with a total of ~243000 depreciation schedules.

The solution:

I've converted the python logic to sql. Now, MariaDB returns all data almost ready to print.

The results:

Now, the report takes ~22 sec the first time it's executed and then, if you change the filters it takes ~1 sec. The server does not die.

Note: The report had a nested loop, it was doing some calculations for each schedule of each asset. Moreover, it was using frappe.get_doc with each asset, instead of frappe.get_value (with just the necessary values). Anyway, all of that is a thing from the past, now almost everything is done in sql.

Info from comments in #17421
The SQL query cannot be broke down. Except in a graphical form, like, splitting it in different strings to comment in between, if that's what you mean it can be done, but I think that it is worst to understand it that way.

For the other comment, yes, there is the prepared report feature, I know it, but, with it, this report is still going to consume a lot of resources and is still going to demand a lot of time, but in the background. That's not a solution, it's like hiding the problem. And I'm not sure if it hides it completely, because it's probably that the server still freeze.

Don-Leopardo added 16 commits Jul 23, 2019
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
…otfix
@nabinhait nabinhait self-assigned this Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.