bhima icon indicating copy to clipboard operation
bhima copied to clipboard

Improve performance of stock dashboard

Open jniles opened this issue 3 years ago • 6 comments

The stock dashboard uses queries that take far too long to load and crashes the server on most low-end devices. We should optimize these queries so that someone doesn't inadvertently kill the server by trying to load the dashboard.

jniles avatar Jun 01 '22 08:06 jniles

Should we temporarily disable this page for now until this issue is resolved?

jmcameron avatar Jun 01 '22 08:06 jmcameron

I'm not sure how to do that in a way that isn't as much effort as just fixing it. Got any ideas?

jniles avatar Jun 01 '22 08:06 jniles

Can't you disable that page via the permissions?

On Wed, Jun 1, 2022 at 9:28 AM Jonathan Niles @.***> wrote:

I'm not sure how to do that in a way that isn't as much effort as just fixing it. Got any ideas?

— Reply to this email directly, view it on GitHub https://github.com/IMA-WorldHealth/bhima/issues/6659#issuecomment-1143281286, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAPFQLSUI4GK7UXGYF5C73VM4NKRANCNFSM5XQGUWQA . You are receiving this because you commented.Message ID: @.***>

jmcameron avatar Jun 01 '22 08:06 jmcameron

That would be a script we run in each production site?

Given how long it takes to coordinate connecting to each site, I would suggest that we do a fix, then do an upgrade that contains that fix. But I could be swayed.

jniles avatar Jun 01 '22 09:06 jniles

I'm not sure how to do that in a way that isn't as much effort as just fixing it. Got any ideas?

I'm not sure how involved it would be to optimize the queries to make this faster. We could stick SQL queries to disable the permissions for that page as part of the migration file and restore it later. We would need to send an email to the admins with small servers not to re-enable that permission for now.

jmcameron avatar Jun 01 '22 12:06 jmcameron

After taking a quick look at this issue, it seems like there are at least two simple things to do to improve the performance of the Stock Dashboard:

  • Add a search filter and default the time period to the last year. Currently all the panels search for 'allTime' period. It is not clear that lots from years in the past are relevant if they have not been used recently. In any case, the filter would allow searching for 'allTime' if desired.
  • Each panel does its own "stockLots()" or "stockInventories" query. This could be reduced to one more general SQL query (eg 'stockLots()' and then do the filtering for each dashboard with the result of the SQL query. Note that this should not be much slower than 'Articles in Stock'.

jmcameron avatar Jan 23 '24 09:01 jmcameron