Repository navigation
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? |
| @@ -2664,7 +2664,7 @@ class Model { | |||
| * @param {Object} options destroy options | |||
There was a problem hiding this comment.
Remove all changes from this file, it is ok to have this as a documentation only warning.
There was a problem hiding this comment.
@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.
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.
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.
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.
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 testornpm run test-DIALECTpass 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.