Re: Large_number_od_records_problem



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 .
.



Relevant Pages

  • Large_number_od_records_problem
    ... so I wan't to do it in chunks and using EJB. ... 1.Load a chunk of data from one table (first 100 ID-s) ... One requirement is that if some exception occurs during persisting let's say ... EJB 3.0 dosn't support nestes transaction, ...
    (comp.lang.java.programmer)
  • Re: data Archiving
    ... rows in appropriate chunks. ... Vyas, MVP (SQL Server) ...
    (microsoft.public.sqlserver.programming)
  • Re: Generating one table with a terabyte of data
    ... I've locked SQL server to 1/3 physical memory usage. ... DB growth is 512Meg ... > I've locked SQL server to 1/3 physical memory usage. ... > chunks. ...
    (microsoft.public.sqlserver.dts)
  • Disk Alignment
    ... I recently read some information regarding aligning the Disk for use with SQL ... disk drive SQL Server writes to should be configured to work in 64KB chunks. ... Here is the Microsoft article. ...
    (microsoft.public.sqlserver.setup)
  • Re: D2006 hits the UK
    ... Jim Cooper wrote: ... Both VS2005 and SQL Server 2005 have large chunks of .NET code in them for instance. ...
    (borland.public.delphi.non-technical)

Loading