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

Optimize DB queries where many-to-many relationships are used #222

Open
anderspeders opened this issue Nov 1, 2016 · 4 comments
Open

Optimize DB queries where many-to-many relationships are used #222

anderspeders opened this issue Nov 1, 2016 · 4 comments
Assignees
Labels

Comments

@anderspeders
Copy link

image

I am wondering where the performance issue is located. Or maybe I was just unlucky...

@anderspeders anderspeders changed the title A lot of pinwheel on project pages A lot of pinwheel on project and country pages Nov 7, 2016
@anderspeders
Copy link
Author

Adding Nigeria country page to this bug report:

image

@KseniyaKuprina
Copy link
Contributor

I need access to the prod to do proper debugging. Please share it.

@iprunache
Copy link
Contributor

@KseniyaKuprina how can we help with access to prod? What kind of access do you need?

@mattfullerton mattfullerton changed the title A lot of pinwheel on project and country pages Optimize DB queries where many-to-many relationships are used Nov 10, 2016
@mattfullerton
Copy link
Contributor

There are a lot of lines like this in the controllers:
https://github.com/NRGI/ResourceProjects.org/blob/master/server/controllers/companies.js#L63

This is starting to become a problem: If our first query returns a lot of (in this case, but many controllers are affected) companies, then a lot of new queries result. This has two issues:

  • It is slow (lots of I/O)
  • It may be resulting in overloading the cluster and destabilizing the whole application due to broken DB connection (unconfirmed but suspected)

The fix would be to stuff all the entity IDs into an array and only run one query on the links to return all links with any of those (e.g.) company IDs. Then with the result of that query the entity can be populated with the information from the relative links relating to that entity.

@KseniyaKuprina At the moment this issue is assigned to you but let me know if you need assistance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants