in reply to Re^2: How to improve MYSQL search performance of perl?
in thread How to improve MYSQL search performance of perl?
You should put your connection stuff in an initialization subroutine, then prepare your SQL-statement once, using place-holders as follows: " my $sth = $dbh->prepare('select topic FROM table1 WHERE uri LIKE ?');" (added benefit: you don't have to worry about quoting!) and then hand off the $sth-variable and the search-argument to your search-subroutine which calls the execute-method with the search string as its parameter:
my ($statement_handle, $search_argument)=@_; $statement_handle->execute($search_argument); ...
Do you get the idea!
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to improve MYSQL search performance of perl?
by nan (Novice) on Aug 24, 2005 at 17:11 UTC | |
by CountZero (Bishop) on Aug 24, 2005 at 18:29 UTC | |
by nan (Novice) on Aug 25, 2005 at 15:56 UTC |