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

Too many SELECT queries on startup #2

Closed
cope opened this issue Oct 19, 2017 · 4 comments
Closed

Too many SELECT queries on startup #2

cope opened this issue Oct 19, 2017 · 4 comments

Comments

@cope
Copy link
Contributor

cope commented Oct 19, 2017

We recently switched from sails-oracle-db to sails-oracle-database and that one switch caused our startup time to go from 7s to 93s.

Upon setting logQueries: true, we see a huge amount of SELECT queries being executed on startup.

Is this neccessary and is there any way to prevent it from happening?

Initially I thought it was the migrate:'alter' problem, but even after setting migrate:'safe', the same thing still happens.

@lucianmachado
Copy link
Owner

Hey @cope, this occurred because waterline checks all mapping's models in the database.. If you're using setting migrate:'safe' and had mapped a model that doesn't exist's in your database a error is going to occur otherwise if you're using migrate:'alter' and mapped structure that doesn't exist in the database it's going to be created.

About prevent it from happening I can check this, initially I think that is possible and I can make it configurable like logQueries option.

I have plans to refactor this lib to get better performance in queries that use complex joins in next months and your suggestion will be included in my task list 😄

But if you want to contribute, all help and suggestions will be appreciated.

Regards.

@cope
Copy link
Contributor Author

cope commented Oct 20, 2017

Hey @lucianmachado, awesome, thanks!

I'm using migrate:'safe'.

If you give me a hint where to look, I can certainly try to contribute.

On a side note, we found an issue with case-insensitive filtering, so I created a pull request to waterline-sequel, would love to hear what your oppinion on that fix is: balderdashy/waterline-sequel#105

@lucianmachado
Copy link
Owner

Hey @cope,

I'm back with good news. I had updated this adatper and a lot of fixes and optimizations were made, including your sugestion. But for curiosity purpose, this is the function who execute all that queries.

About your fix, unfortunately it don't fix on this adapter but I did a workaround to fix this bug in this adapter. Case insensitive filtering was known bug since I forked this adapter.

If you update the module in your project you'll realize these things:
-Now this adapter are using ResultSet to fetch rows, so performance (speed and memory) may be affected.
-The structure verification are disabled by default, so startup time are very fast now.
-Possibility to control the data pool.

In our last contact you asked me about a hint, I think for better understanding you can see this example of a adapter:
https://github.com/balderdashy/sails-adapter-boilerplate/blob/master/index.js

I wish refactor this since I forked but my focus is to make it stable, so if you find an another bug feel free to send a pull request or open an issue. All help always will be apreciate.

Best regards!

@cope
Copy link
Contributor Author

cope commented Nov 6, 2017

Hey @lucianmachado,

After uninstalling and reinstalling the package, I can confirm that the startup time is now perfect!

Thanks!

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

No branches or pull requests

2 participants