How to Check Query Execution Time in PHP?
Hi Artisan,
This tutorial shows you how to check query execution time in php. If you have a question about php query execution time then I will give a simple example with a solution. This example will help you php get query execution time. This tutorial will give you a simple example of how to get query execution time in php.
If you are looking for how to get sql query execution time in php then i will give you simple example for it. we will use microtime() function to calculate query execution time in php.
so, let's see the simple example code:
index.php
<?php
$startTime = microtime(true);
$connection = new mysqli("localhost","root","root","laravel10_crud");
$result = mysqli_query($connection, "SELECT * FROM users");
$endTime = microtime(true);
$executionTime = $endTime - $startTime;
echo "Query took " . $executionTime . " seconds to execute.";
?>
Output:
Query took 0.0032229423522949 seconds to execute.
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel 10 Cron Job Task Scheduling Tutorial
- Ubuntu PHP bz2 Extension Install Commands Example
- How to Remove HTML Tags from String in Laravel?
- How to Use Enum in Laravel?
- PHP MySQL Column Sorting Example Tutorial
- How to Make Read More Link from String in PHP?
- How to Remove Duplicate Values from Array in PHP?
- How to Get File Name without Extension in PHP?
- How to Increase Upload File Size Limit PHP in Ubuntu?
- How to Check If String is URL or Not in PHP?
- How to Count Number of Files in a Directory in PHP?
- How to Find Day Name from Specific Date in PHP?
- How to Get Query Log in Laravel Eloquent?