Open cheerfulstoic opened 6 years ago
It's been a while since I've had to do this in ActiveRecord, so I don't remember if AR makes multiple DB requests. I DO remember that AR passes multiple insert queries to the DB, which is very inefficient. The ActiveRecord import gem specifically fixes this problem.
I think an analogous scenario in Neo4j would be sending 10 batched queries to the DB (in order to create 10 nodes) as part of one http request VS sending one query in which you unwind a param in order to create 10 nodes.
I don't remember if AR validates the objects.
Yeah, I've definitely created some functions to help emulated part of what activerecord_import does. It would definitely make sense to send multiple queries in one HTTP request, though probably it would be good to start pushing toward Bolt which (I don't think) has the same tradeoff in sending multiple queries in one network request
In
ActiveRecord
you can pass in an array of hashes where the hashes has the properties of the nodes that you want to create and it creates many at the same time.ActiveNode
should support the same functionality.Open question: Does
ActiveRecord
actually create the objects in memory and validate them before saving? Does it make multiple DB requests?