Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

node.js - Insert millon data with TypeOrm and Oracle

I am currently having a problem, I need to insert a large amount of data, greater than 100K into an Oracle database from node using TypeOrm. The problem is that when using the ".save ()" method, if the amount of data exceeds 4000 rows, the data is duplicated in Oracle and I do not understand the reason, besides that it takes too long to insert, approximately 30min in 150K records.

What is the most efficient way to insert a large amount of data in a small amount of time?

question from:https://stackoverflow.com/questions/65545987/insert-millon-data-with-typeorm-and-oracle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Bulk inserts can be performed according to the documentation here:

import {getConnection} from "typeorm";

await getConnection()
    .createQueryBuilder()
    .insert()
    .into(User)
    .values([
        { firstName: "Timber", lastName: "Saw" }, 
        { firstName: "Phantom", lastName: "Lancer" }
     ])
    .execute();

This is the most efficient way in terms of performance to insert rows into your database. You can also perform bulk insertions this way.

I'm not sure about the duplicate issue you are facing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...