in reply to speeding up a regex
One thing you could do to speed things up is to let SQL do what it is good for. For example, say your $data->[10] row is called 'database'. Then get SQL to remove everything that has 'tempdb' in it with a WHERE database NOT LIKE '%tempdb%'. And also, if your list of keywords to search for are never actually regexes, just a list of keywords, then you can add something like:
I would achieve that by some code like this probably.WHERE database NOT LIKE '%tempdb%' AND ( keyword LIKE '%create%' OR keyword LIKE '%delete%' OR keyword LIKE '%insert%' ... )
my @patterns = qw/create delete insert update drop/; my $query = "@sqlstatement"; # don't know what you already have in @sq +lstatement though $query .= qq{WHERE database NOT LIKE '%tempdb%'; $query .= qq{AND (}; $query .= join " OR ", map { qq{keyword LIKE '%$_%'} } @patterns; $query .= qq{)}; sth=$dbh->prepare( $query ); $sth->execute; while ($data = $sth->fetchrow_arrayref()) { # the query did all of our checking, so we don't need to check anyt +hing. print "$data->[3] $data->[9] $data->[10] $data->[13]\n"; }
-Bryan
|
|---|