Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I show the query time in Perl, DBI?

Tags:

mysql

perl

dbi

I use Perl and DBI to manage my MySQL tables, querys, etc. How can I show the running time of a query?

If I do a SELECT in the console, the result will be like this:

+-----+-------------+
| id  | name        |
+-----+--------------
|   1 | Jack        |
|   2 | Joe         |
|   3 | Mary        |
+-----+-------------+
3 rows in set (0.17 sec)

I need to show 0.17 sec. There is any way in DBI to show the running time in Perl, something like this?

my $dbh = $db->prepare("SELECT id, name FROM names ORDER BY id;");
$dbh->execute;
print $dbh->runnin_time; # ???
like image 851
netdjw Avatar asked May 29 '12 12:05

netdjw


1 Answers

DBI#Profile, DBI::Profile, DBI::ProfileData, DBI::ProfileDumper, dbiprof

like image 187
daxim Avatar answered Oct 26 '22 01:10

daxim