Slow Sql queries module for v3 opencart

keni2008

New member
XNullUser
Joined
Nov 19, 2024
Messages
2
Reaction score
0
Points
1
Location
Miami
NullCash
9
The module allows you to obtain a log of slow SQL queries for subsequent debugging of the website's loading speed. The log is saved at the address ../system/logs/sql_time.log.

To change the time limit for logging queries, you need to modify the line in the XML:

Code:
$min_time = 10; // minimum execution time of the query in ms to be logged

What is written in the log:

  • page generation time
  • number of queries on the page (total and slow)
  • list of slow queries and their execution times
  • which file and which function is calling the query
Example:

►► Page: /index.php?route=product/product&product_id=33 Generation time: ~116.71ms Number of queries: 13

Slow queries (1):

  1. Source: system\storage\modification\catalog\model\catalog\product.php → updateViewed Execution time: 1.59ms
    UPDATE oc_product SET viewed = (viewed + 1) WHERE product_id = '33'

end​

Don't forget to deactivate the module after your work is done; otherwise, the log file will grow for months until it fills up the available space!
 

Attachments

  • sql_query_time_log_ALPHA.ocmod.xml
    3.4 KB · Views: 0
Top