Questions tagged [batch-insert]

152 questions
89
votes
6 answers

Java: Insert multiple rows into MySQL with PreparedStatement

I want to insert multiple rows into a MySQL table at once using Java. The number of rows is dynamic. In the past I was doing... for (String element : array) { myStatement.setString(1, element[0]); myStatement.setString(2, element[1]); …
Tom Marthenal
  • 2,856
  • 3
  • 27
  • 45
36
votes
1 answer

ActiveRecord batch insert (yii2)

Is it possible to insert multiple rows in one query with Yii's ActiveRecord? Or is this only possible via the lower-level DAO objects? I have two models 1- Transaction 2-TransactionItems There are multiple rows(onclick add row) in transaction…
user1561346
  • 672
  • 3
  • 12
  • 26
23
votes
5 answers

Batch inserts with JPA/EJB3

Does JPA/EJB3 framework provide standard way to do batch insert operation...? We use hibernate for persistence framework, So I can fall back to Hibernate Session and use combination session.save()/session.flush() achieve batch insert. But would like…
Raja
  • 261
  • 1
  • 2
  • 6
21
votes
4 answers

Need to insert 100000 rows in mysql using hibernate in under 5 seconds

I am trying to insert 100,000 rows in a MYSQL table under 5 seconds using Hibernate(JPA). I have tried every trick hibernate offers and still can not do better than 35 seconds. 1st optimisation : I started with IDENTITY sequence generator which…
Kumar Manish
  • 985
  • 1
  • 9
  • 25
18
votes
5 answers

How to multi insert rows in cassandra

What is the most efficient way of inserting multiple rows in cassandra column family. Is it possible to do this in a single call. Right now my approach is to addinsert multiple column and then execute. There in a single call I am persisting one row.…
ajjain
  • 1,081
  • 2
  • 14
  • 27
15
votes
5 answers

How can I do a batch insert into an Oracle database using Python?

I have some monthly weather data that I want to insert into an Oracle database table but I want to insert the corresponding records in a batch in order to be more efficient. Can anyone advise as to how I'd go about doing this in Python? For example…
James Adams
  • 7,338
  • 18
  • 68
  • 113
14
votes
5 answers

T-SQL, Insert into with MAX()+1 in subquery doesn't increment, alternatives?

I have a query where I need to "batch" insert rows into a table with a primary key without identity. --TableA --PK int (Primary key, no-identity) --CustNo int INSERT INTO TableA (PK,CustNo) SELECT (SELECT MAX(PK)+1 AS PK FROM TableA), CustNo …
KorsG
  • 709
  • 1
  • 7
  • 16
14
votes
1 answer

Batch insert in Laravel 5.2

I am using a API's with lot's of calculation almost 100 database fields at the end with a big Foreach loop. In every iteration i insert data in database. I want to insert data in once at the end (Batch Insert like in CodeIgniter). Any body have…
Irfan Ali
  • 201
  • 1
  • 3
  • 5
13
votes
5 answers

How to perform batch update in Spring with a list of maps?

New to Spring, I am trying to insert a List> into a table. Until now I have been using the SqlParameterSource for batch update, which works fine when a java bean is supplied to them. Something like this: @Autowired …
Mono Jamoon
  • 3,967
  • 15
  • 36
  • 59
12
votes
3 answers

Massive insert with JPA + Hibernate

I need to do a massive insert using EJB 3, Hibernate, Spring Data and Oracle. Originally, I am using Spring Data and code is below: talaoAITDAO.save(taloes); Where talaoAITDAO is a Spring Data JpaRepository subclass and taloes is a Collection of…
Rafael Afonso
  • 535
  • 1
  • 8
  • 24
11
votes
2 answers

How to get generated keys from JDBC batch insert in Oracle?

I am inserting many records using JDBC batch inserts. Is there any way to get the generated key for each record? Can I use ps.getGeneratedKeys() with batch inserts? I am using oracle.jdbc.OracleDriver final String insert = "Insert into…
atripathi
  • 828
  • 2
  • 9
  • 17
8
votes
3 answers

Codeigniter Insert Multiple Rows in SQL

I am fresh to Codeigniter. I have a form which looks something like this.
Mr Hyde
  • 3,341
  • 8
  • 33
  • 47
8
votes
1 answer

JPA(Hibernate) and postgres sql batch upsert using nativequery

I would like to perform a batch upsert with JPA and Postgres. I can't use merge as I am checking conflict on a Unique Constraint which is not PK. I found that to upsert in postgres we can now use the ON Conflict functionality. So basically I would…
7
votes
2 answers

Hibernate - how to verify if batch insert is really performed

Technology stack: Oracle database 11.2.0.2, Java 1.6, Hibernate 3.6.6.Final. I am new to hibernate, apologize if this is trivial. The following code was supposed to put some optimization: Transaction tx = session.beginTransaction(); for (int i = 0;…
Łukasz
  • 1,438
  • 3
  • 21
  • 40
7
votes
4 answers

Inserting large number of records without locking the table

I am trying to insert 1,500,000 records into a table. Am facing table lock issues during the insertion. So I came up with the below batch insert. DECLARE @BatchSize INT = 50000 WHILE 1 = 1 BEGIN INSERT INTO [dbo].[Destination] …
Pரதீப்
  • 85,687
  • 16
  • 112
  • 148
1
2 3
10 11