Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: sql
sqlperformancetransactionsbulk
Prefer an INSERT...SELECT over a find-then-bulkCreate pair
A read followed by a bulk insert can often be a single INSERT INTO ... SELECT, which is fewer round trips and atomic.
PR: vinify-backend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const rows = await repo.findAll(where); |
| 2 | await repo.bulkCreate(rows.map(map)); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codesql
| 1 | await sequelize.query('INSERT INTO t (...) SELECT ... FROM s WHERE ...'); |
Explanation (EN)
Objašnjenje (HR)