How to Bulk Insert Data With Laravel

preview_player
Показать описание
As programmers, we often need to bulk insert a massive number of records into a database. Some languages and platforms offer built-in tools that make bulk insert a trivial thing. PHP (and Laravel), however, don't have these tools. But we can still efficiently bulk insert data! Let me show you how in this Larabit.

Рекомендации по теме
Комментарии
Автор

Great speaker and a useful video! Thanks 👍

biryuk
Автор

Thanks for the video.. One Note: Disabling foreign key check in a production app, can lead to slowdown or worst case an error inserting an id a does not exists on parent, so for your safety i would skip disabling foreign key check

JoseFranciscoIT
Автор

Using DB:: instead of the Model class should speed up the process quite a bit

OliverKurmis
Автор

Truely went all the way with the bulk insert scenarios, good vid!

DirkZz
Автор

Great video but last option is good only for simple import. If you need some checking, other laravel/php stuff to do before/during insert then we are doomed :D

rafamorawiec
Автор

I think using queues with chunking is also useful in this case, e.g chunking the file and storing 10k records into the database during each queue iteration

arthmelikyan
Автор

Hi, This is a great way of inserting for a single table and where don't need to perform any functionality but if we want to perform some functionality and store the data in to different tables. Can you please cover that topic as well? I know that can be handled with queues but I wasn't able to implement it in an efficient way instead I overloaded the database with many mini jobs.

shahzadwaris
Автор

Amazing. Please share some ideas about database design for scalable Laravel app.

grugbrain
Автор

Thank you for sharing such a value and informative video.

This is my first time reaching your channel. I am gonna follow you and share this vid.

I have a question.

Is it suitable to use Transaction and Commit for bulking tons of record like this?

edventuretech
Автор

This is a great larabit. Thanks for the video Jeremy!

swancompany_inc
Автор

Which platform you use in which you give that data and just say do it.?

vpfwujd
Автор

great content, tqs for sharing valuable information with laravel developers, tq you very much.

shaikhanuman
Автор

Can I use bulk insert to get data from api and insert to my database?

docetapedro
Автор

That’s amazing, thanks for the video, excellent well done 👍🏽

franciscojunior
Автор

great video, super useful, please more like this 🤩

vic_casanas
Автор

What about exporting INSERT statements to a SQL file and using MySQL dump to import the file? Would that be more memory efficient in some cases?

underflowexception
Автор

Note for me before watching the full video: php generator will be the option to read such big sized files line by line. Lets see if I am right or wrong.

mohammadashrafuddinferdous
Автор

Chunking is way more available than threading. Still better than none at all.

IndraKurniawan
Автор

League/csv has been using generators for a long tim e now. I don't g et why you would use laravel and then not use a package like csv/league

Fever
Автор

What if we collect the information into an array named $data during the loop and then execute a single database insert query, similar to using

wadday