Is there a way that I can get the time of a MySQL query (specifically with PHP)? The actual time it took to complete the query, that is.
Something such as: Results 1 - 10 for brown. (0.11 seconds)
I tried to look for an example, to no avail. Here is an example of my code:
// prepare sql statement
$stmt = $dbh->prepare("SELECT ijl, description, source, user_id, timestamp FROM Submissions WHERE MATCH (ijl, description) AGAINST (?)");
// bind parameters
$stmt->bindParam(1, $search, PDO::PARAM_STR);
// execute prepared statement
$stmt->execute();
For my current full text search using a MyISAM table engine. Any help would be incredible. Thank you.
Now, go to the Scalyr dashboard menu and select MySQL. You will be able to see the log details of your MySQL, which includes the query time. This is a very simple and easy way to measure query time for a large number of MySQL queries.
mysqli_num_rows ( $result ); Parameters: This function accepts single parameter $result (where $result is a MySQL query set up using mysqli_query()). It is a mandatory parameter and represents the result set returned by a fetch query in MySQL. Return Value: It returns the number of rows present in a result set.
PHP is the most popular scripting language for web development. It is free, open source and server-side (the code is executed on the server). MySQL is a Relational Database Management System (RDBMS) that uses Structured Query Language (SQL).
$starttime = microtime(true);
//Do your query and stuff here
$endtime = microtime(true);
$duration = $endtime - $starttime; //calculates total time taken
NOTE that this will give you the run time in seconds(not microseconds) to the nearest microsecond due to get_as_float
parameter being true. See this
this may be help you
http://dev.mysql.com/doc/refman/5.0/en/show-profile.html
mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE TABLE T1 (id INT);
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW PROFILES;
+----------+----------+--------------------------+
| Query_ID | Duration | Query |
+----------+----------+--------------------------+
| 0 | 0.000088 | SET PROFILING = 1 |
| 1 | 0.000136 | DROP TABLE IF EXISTS t1 |
| 2 | 0.011947 | CREATE TABLE t1 (id INT) |
+----------+----------+--------------------------+
greetings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With