Snippets is where I collect knowledge about science, web development, data and code.

This is more for me to be able to easily recall small bits of information I find on the internet, but you may find some of these useful.

Laravel – `syncWithoutDetaching()` vs `insertOrIgnore()`

  • Post category:Snippets

In a tweet by Tom Herrmann (@devgummibeer) (https://gummibeer.dev/), he discussed how using syncWithoutDetaching() call can kill a database. Basically, instead of doing: $user->identifiers()->syncWithoutDetaching($identifiers); Do this: DB::table('identifier_user')->having()->insertOrIgnore( $identifiers->map(fn (Identifier $identifier) =>…

Continue ReadingLaravel – `syncWithoutDetaching()` vs `insertOrIgnore()`