SQL Server 50000 insert too slow

3hvapo4f  于 2023-05-05  发布在  SQL Server
关注(0)|答案(1)|浏览(185)

I have a load of data which consists of only 2 columns as 50000 rows in MS Excel. I created an insert query using some concat() functions and got a list of insert queries (additional info in file:

insert into X_Table (Id, NewId) 
values (14878, 1000009442)

However, when I try to run the insert statements, it inserts only 50-60 rows per minute, which I would argue is extremely slow.

Note that there is no single index, column or any sort of handicap in the table.

Which steps should I take to analyze why this happens? Or if have any direct answer, which you may have already encountered, please, let me know the solution.

yyyllmsg

yyyllmsg1#

It took seconds to insert all the rows on my local PC.

In the c column of the Excel sheet, I have written this formula:

="insert into X_Table (Id, NewId) values ("&A1&", "&B1&");"

I got these SQL statements:

insert into X_Table (Id, NewId) 
values (14878,1000009442);
insert into X_Table (Id, NewId) 
values (14867,1000001802);
insert into X_Table (Id, NewId) 
values (14876,1000004098);
insert into X_Table (Id, NewId) 
values (14796,1000000673);
insert into X_Table (Id, NewId) 
values (14932,1000009255);
insert into X_Table (Id, NewId) 
values (14831,1000011692);
insert into X_Table (Id, NewId) 
values (14977,1000002093);
insert into X_Table (Id, NewId) 
values (14721,1000004031);
insert into X_Table (Id, NewId) 
values (14759,1000005564);
insert into X_Table (Id, NewId) 
values (14796,1000002776);
insert into X_Table (Id, NewId) 
values (14706,1000005490);

All 50'000 rows have been inserted within 6 seconds. Please try this.

相关问题