The Magento database profiler displays all queries executed on a page, including the time for each query and what parameters were executed.
Step 1: Modify the deployment configuration
Modify <your Magento install dir>/app/etc/env.php to add the following reference to the database profiler class:
An example follows:
Step 2: Configure the output
Configure the output in your Magento application boostrap file; this might be <your Magento install dir>/index.php or it could be located in a web server virtual host configuration.
The following example displays results in a three-column table:
Total time (displays the total amount of time to run all queries on the page)
SQL (displays all SQL queries; the row header displays the count of queries)
Query Params (displays the parameters for each SQL query)
To configure the output, add the following after the $bootstrap->run($app); line in your bootstrap file:
Step 3: View the results
Go to any page in your storefront or Magento Admin to view the results. A sample follows: