Surpac - MS Access Trick

Macros TCL/SCL I'm working with a relatively large drill hole database (16k holes, 1.1M assays); my scripts require a lot of work in temporary fields where I'm creating a capped/cut assay value, eg something like this in the assay table:

expr=table { result_field expression } {
  { "au_ppm_cap" "IIF(au_ppm > \\\$auCap, \\\$auCap, au_ppm)" }
  { "as_ppm_cap" "IIF(as_ppm > \\\$asCap, \\\$asCap, as_ppm)" }

 

or another one where I'm combining a number of similar geology zones into a single zone for compositing:

set status [ SclFunction "FIELD MATHS" {
  frm10090={
	 {
		table_name="intercept_table"
		expr={
		  {
			 result_field="temp_code"
			 expression="\\"\\\${zoneCode}_\\\${passNum}\\""

And these operations occur at least once per "pass", sometimes as many as twelve times in a single pass, writing data into alternate fields in the assay and geology tables.  Once complete, the database has increased in size from the original 233Mb to 448Mb which affects the loading time as well as processing times.  (old man moment ... this problem has been around since Surpac made a connection to the Access databases in 1998(?) ... Paradox databases never had this problem and were WAAAYYYY faster, but no one has Paradox anymore!)

You can correct the problem by using the "Compact & Repair" feature in Access to "pack" the records and reduce the size. I managed to find something this week where I can code it into the script as a proc, compacting as I go after every pass. 

proc CompactDatabase {databaseName} {
    # puts "[file join [SclLogical translate PROJ_DATABASE: /] [file rootname \\\$databaseName].accdb]"
    # Compact the database, decreases size and makes the database a bit faster
    exec "C:/Program Files/Microsoft Office/root/Office16/MSACCESS.EXE" "[file join [SclLogical translate PROJ_DATABASE: /] [file rootname \\\$databaseName].accdb]" /compact 
}

CompactDatabase test1.ddb

Effectively, we are using Tcl, inside of Surpac to execute Access and compact the database with the /compact switch.

In my particular case, compacting reduced processing time from about 20hrs to 16hrs. Still not lightening quick, but faster. Will continue to play with faster processing options but thought I'd share this one with the group.