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
docs(hooks.md, model.js): add warnings about memory limitations of individualHooks #9881
Conversation
Codecov report that coverage will decrease is totally bogus, I haven't changed any code at all. Are there race conditions in the tests? |
lib/model.js
Outdated
@@ -2664,7 +2664,7 @@ class Model { | |||
* @param {Object} options destroy options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all changes from this file, it is ok to have this as a documentation only warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sushantdhiman what do you think is the downside to also warning in this file?
The Sequelize documentation is large and a warning in the tutorial could be easily missed (IIRC I learned about individualHooks
in the reference docs before seeing it in the tutorial docs.) Having this warning in more places makes it more likely that devs will see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API docs should not cover such warnings or expanded explanation, they should only explain working of any give option and platform limitation if any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, would it be okay for the API docs to simply say "all instances will be fetched into memory before running hooks"? That is explaining what it does...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT all records matching the where parameter...
it should be clear by that. SELECTED records will be loaded to memory and large SELECT surface will consume more memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I removed the changes to model.js
0b15bed
to
72d9886
Compare
Pull Request check-list
Please make sure to review and check all of these items:
Not applicable, this is a document only change
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
I was very disappointed to realize today that if were to update or destroy a billion instances with individual hooks, Sequelize would try to fetch all billion of them into memory before running the individual hooks. I had mistakenly assumed it would iterate through them in batches or using cursors of some kind...
I wish I had been warned about this before I decided to start using hooks, so I'm adding this warning to the docs.