Thursday, March 10, 2011

Spring cleaning your APEX instance

While I was working on my (and Marco's) presentation for Kscope11 about the XFILES, I discovered some trash under the XML DB carpet of my database. If I executed the statement 
select * from RESOURCE_VIEW
where under_path( res, 1, '/')=1
I got (amongst others)
So apart from the standard "images" directory, there where three more... 
When you upgrade an APEX instance the old images directory is renamed (a datetime-stamp is added) and a new one is created - just in case you need to fall back on your old stuff. If you use a webserver the presence of that directory is easy to see - and to delete. 
When using the Embedded PL/SQL Gateway (EPG) the same procedure is applied, but now you probably wont notice, until you look for it...
To get rid of the old stuff run (of course use your own images directory instead of mine):
begin
  dbms_xdb.deleteresource( '/images_201102071025'
                         , dbms_xdb.delete_recursive);
  commit;
end;
After running that PL/SQL block three times - for all three old images directory, the number of records returned from RESOURCE_VIEW is dramatically decreased : from 42,349 to 12,268. Doing this clean up  saved me some space and improved performance (on certain queries that is). 
Post a Comment