Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Millions of Rows from another table

Tags:

sql

bigdata

Faster way to insert rows into a table from a select statement and insert into?

Insert into PartyMain
Select [PermID]
      ,[IsOptOut]
      ,[UpdatedOn]
      ,[FK_DataSource]
 From PartyMain

with 6M rows is taking > 4 minutes

like image 931
Marty Trenouth Avatar asked Nov 28 '25 06:11

Marty Trenouth


1 Answers

insert via select is the fastest way i can think of to insert data. You might be able make improvements in you app work flow, however.

I imagine have some sort of button in an app that kicks off the process. Instead of doing the insert when a user tells the app to (Im making that assumption), can you have a process that runs every X seconds that does the transfer? Or alternatively check every X seconds and if the number of rows to transfer is greater than Y, run the transfer...So in other words, dont wait until there are 6 million rows.

Edit- another options might be database triggers.

like image 63
hvgotcodes Avatar answered Nov 29 '25 21:11

hvgotcodes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!