News for hackers. Stuff that matters.
Re:Push ifs up and fors down by mdavidn on Thursday November 16, 2023 @08:06AM (#38289060)
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.

There are no comments on this comment yet.