in reply to Optimization for Speed w HTML to Database processing

This is just a guess, as I am not sure what bpoStub is. I looked for on CPAN and other places and couldn't find a reference to it, so I am assuming that it's an in-house module.

When I use the DBI module, executing SQL takes two or three steps: creating the SQL, preparing it (I can combine the "create" and "prepare" into one step) and executing it. It looks like you are combining the "prepare" and "execute" steps with bpoStub:

my $D = new bpoStub; . . . $sql = "select DBCompNum from FieldMap where DBTable=\"$DBTable\" and FormID = $FormID group by DBCompNum"; @rowscomp = $D->select($sql); for $countc ( 1 .. $#rowscomp ) { . . . }
If that is the case, I suspect that part of your problem is how you are doing the sql. Consider the following:
use DBI; . . . my $sql = 'INSERT INTO ' . $table . '(title, description, filename, pa +th) VALUES (?, ?, ?)'; my $sth = $dbh->prepare($sql); while ($some_condition) { $sth->execute( $title, $description, $filename, $storagePath ); # do stuff which modifies condition and perhaps # the insertion values }
The question marks (VALUES (?, ?, ?)) in the SQL are placeholders. When it is "prepared", DBI prepares the sql and then inserts whatever values you pass to it with $sth->execute. Because the "prepare" statement has a high overhead, you should never prepare SQL inside of a loop if you can avoid it. It looks like your SQL is static, except for the variables that you pass. If that is the case, prepare all of your SQL outside of the loops you have and execute inside of the loops.

On a side note, I also spotted this regex in a loop:

if ( $Type{$DBCol} =~ /numeric|float|int|money/ ) {...}
That regex will be recompiled every time it is encountered, also increasing your run time. Since it is also static, add the /o modifier to force the regex compiler to compile it only once during the run, thus saving time.

Further, I am guessing that $type{$DBCol} is not likely to have a space prior to the column type. Using ^ at the beginning of the regex will force it to match at the beginning. Otherwise, it will try every character after the first for a match, thus increasing run time.

if ( $Type{$DBCol} =~ /^numeric|float|int|money/o ) {...}
Hope this helps! Cheers.