in reply to Re^5: How to Limit MySql Execution Time?
in thread How to Limit MySql Execution Time?
#!/usr/bin/perl require 'myconfigure.cgi'; $timeout = 5; use DBI; $keywords = "Whether rocking natural-curls, a-short"; print "Content-type: text/html\n\n"; sub do_search { $time1 = time; $dbh=DBI->connect("dbi:mysql:$database:localhost","$username","$pa +ssword"); $keywords_quoted = $dbh ->quote ($keywords); $query="SELECT count(*) FROM $websites_table WHERE MATCH(title) AG +AINST ($keywords_quoted)"; $sth=$dbh->prepare(qq{$query}); $sth->execute(); $total_count = $sth->fetchrow_array (); $sth->finish; $dbh->disconnect ||die("Couldn't disconnect to database!\n"); $time2 = time; $time_ran = $time2 - $time1; } eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; &do_search; alarm 0; }; if($@) { $time2 = time; $time_ran = $time2 - $time1; print "$@, Time Ran: $time_ran, Total Count: $total_count\n"; exit; } print "Time Ran: $time_ran, Total Count: $total_count\n"; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: How to Limit MySql Execution Time?
by BrowserUk (Patriarch) on Dec 22, 2010 at 07:18 UTC | |
by Anonymous Monk on Dec 22, 2010 at 11:17 UTC | |
by Anonymous Monk on Dec 22, 2010 at 11:45 UTC | |
by Anonymous Monk on Dec 22, 2010 at 13:49 UTC | |
by Anonymous Monk on Dec 22, 2010 at 14:35 UTC | |
| |
by BrowserUk (Patriarch) on Dec 22, 2010 at 11:21 UTC |