Re: Large_number_od_records_problem
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Feb 2009 04:47:20 -0800
On Sun, 22 Feb 2009 22:54:28 +0100, "marko" <mark@xxxxxxxxx> wrote,
quoted or indirectly quoted someone who said :
I have a problem with moving large number of records from one table to
another, so I wan't to do it in chunks and using EJB. This is my idea.
1.Load a chunk of data from one table (first 100 ID-s)
2.Persist data(record matching these ID-s) into second table
3.Delete these 100 records from the first table if 2. went well.
One requirement is that if some exception occurs during persisting let's say
3rd chunk of data (record's no. 301, 302...) whole process is rollback-ed
(none of the record is persisted in the seconf table)
How many session bean-s do I need to write ? And what annotations to use ?
EJB 3.0 dosn't support nestes transaction, right ?
Let the SQL engine do all the work. Just feed it a couple of lines
via JDBC.
insert into table2 select * from table1
where criteria=?
delete from table1 where criteria=?
You really want to treat it as a single transaction. Having it
rollback 50% would possibly not be acceptable. You would have to
experiment to see if chunking buys you any speed.
The big advantage of this approach is no records need be transferred,
from/to the application. The SQL server is free to optimise the
process on its own totally inside the server.
--
Roedy Green Canadian Mind Products
http://mindprod.com
One path leads to despair and utter hopelessness. The other,
to total extinction. Let us pray we have the wisdom to choose correctly.
~ Woody Allen .
.
- References:
- Large_number_od_records_problem
- From: marko
- Large_number_od_records_problem
- Prev by Date: Re: download a web site... or a page of it...
- Next by Date: Re: reversing java to c enum style mapping
- Previous by thread: Re: Large_number_od_records_problem
- Next by thread: How is entrySet getting initialized in HashMap.java ?
- Index(es):
Relevant Pages
|
Loading