Deleting large number of objects

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:25 pm

by David Mellow >> Mon, 2 Feb 2009 20:54:47 GMT

A long shot, unless I'm overlooking the obvious.

If I want to delete a very large number of objects, a few classes in one physical map file, and the only classes in that map, is there a way to delete all of the objects without purge or iterating through them? We are talking millions of objects. Incidentally, slosing the class definitions themselves is fine, it is what we ultimately are doing anyway.

Obviously I can't use delete class in jcf run by jadload, because of all the instances, but that makes me wonder if there is some other way?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:25 pm

by John Beaufoy >> Mon, 2 Feb 2009 21:08:50 GMT

A map file can be deleted programatically, which would be lightning fast in comparison.

If you see this as an option I'll dig up a script for you and outline a few caveats.

Cheers,
JB

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:25 pm

by David Mellow >> Mon, 2 Feb 2009 21:34:56 GMT

Wow, sounds great John, along the lines of what I was hoping was possible. I'd appreciate it. Either here or d.mellow@xtra.co.nz.

Cheers

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:25 pm

by David Mellow >> Mon, 2 Feb 2009 21:40:45 GMT

Thanks John, very much along lines of what I was hoping to be possible.

I am assuming possible to attach here, else d.mellow@xtra.co.nz.

Cheers

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:25 pm

by John Beaufoy >> Mon, 2 Feb 2009 21:54:22 GMT

A few points of note:

This is an undocumented method, as such use it while its available but at your own peril.

All classes defined in the map file will have all their instances removed. If you have classes in there you wish to preserve, there are one-off scripts to port these across to other map files.

Any remaining objects that referenced this now deleted data will be left with invalid object references. If you had a global collection over this data, this will still be full and have to be cleared. Alternatively, you could define the collection as non-exclusive and put it in the map file to be deleted also, leaving only the reference to the collection needing to be set back to null.

The usual "backup your db beforehand" rules apply:

vars
dba : JadeDatabaseAdmin;
dbFiles : DbFileArray;
dbFile : DbFile;

begin
create dba transient;
create dbFiles transient;

// get the list of files
dba.getDbFiles(DbFile.Kind_User_Data, dbFiles);

// remove the specific map file
beginTransaction;
foreach dbFile in dbFiles do
if dbFile.name = "yourMapFileNameGoesInHere" then dbFile._deleteFile;
break;
endif;
endforeach;
commitTransaction;

epilog
delete dba;
delete dbFiles;
end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:25 pm

by David Mellow >> Mon, 2 Feb 2009 22:43:38 GMT

Thanks John. Yeah, like everything this will be going through about 2 levels of testing before live system.

Much appreciated.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:26 pm

by cnwjhp1 >> Mon, 2 Feb 2009 22:42:15 GMT

You can also use jdbutil to delete a map file. Instructions are in DbAdmin.pdf. I presume references from other map files to the deleted objects would need to be tidied up as previously mentioned.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Deleting large number of objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:26 pm

by Jade Support >> Mon, 2 Feb 2009 23:03:10 GMT

The easiest way to increase the performance while maintaining referential integrity is to perform the operation in exclusive no audit mode. This avoids both the locking and auditing overheads associated with bulk delete transactions.

Have a look at the JadeDatabaseAdmin class changeDbAccessMode() method, and the Mode_Archive & Usage_NoAudit parameters.

Regards,
Jade Support.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 29 guests