3 ms·
I have practiced this advice in line-of-business software to great effect. Popular ORM libraries operate on individual records, but that is quite slow when soft
by mdavidn 3y ago
I have practiced this advice in line-of-business software to great effect. Popular ORM libraries operate on individual records, but that is quite slow when software needs to import a large number of objects. Restructuring the code to operate on batches—push fors down—results in significantly fewer database queries and network round-trips. The batched routines can resolve lookups of foreign keys in batches, for example, or insert multiple records at once.
Granted, that is more difficult to maintain. I only batched the import routines. The rest still uses the more maintainable ORM.