Magento Forum

   
SQL Debugging Option
 
nickweisser
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2007-09-03
Zurich, Switzerland
 

This quick debugging tip is very helpful, but not enough when it comes to debugging SQL queries in Magento!

I just read that in v1.1.1 an SQL debugging option was added to the code, but could not find anything about how to trigger this option?

When I log the $select array I see this variable

[_debugFile:protected] => var/debug/sql.txt
as part of the Varien_Db_Select object, but there is nothing being written to var/debug/sql.txt. I created the directory and and empty sql.txt file with full write permissions to no avail.

I’ve seen various threads about debugging questions - most unanswered. It would be very nice to have a Wiki entry about debugging Magento. I read that the Magento team uses Zend Studio for debugging, but as not everybody is using this IDE it would be very nice to have some easy debugging options.

 
Magento Community Magento Community
Magento Community
Magento Community
 
REDMobile
Member
 
Avatar
Total Posts:  42
Joined:  2008-09-15
 

To enable SQL Debugging find the file

/lib/Varien/Db/Adapter/Pdo/Mysql.php

change line 45

protected $_debug               false;

to

protected $_debug               true;

It will then generate the file var/debug/sql.txt

 
Magento Community Magento Community
Magento Community
Magento Community
 
OzzyCzech
Jr. Member
 
Total Posts:  21
Joined:  2009-05-26
Ostrava
 

Thank’s the SQL debug is usefull !!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
anand panchal
Jr. Member
 
Total Posts:  7
Joined:  2009-11-13
 

change the code as you say but not creating sql.txt file.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pronux
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2009-12-15
Switzerland
 

changed the code as you say but it’s not creating the sql.txt file.

Change also the $_logQueryTime on line 91:

protected $_logQueryTime        0.05;

to

protected $_logQueryTime        0.000005;

 
Magento Community Magento Community
Magento Community
Magento Community
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

I use the MySQL GUI Tools to read the SQL server log.

 
Magento Community Magento Community
Magento Community
Magento Community
 
e-thos
Jr. Member
 
Total Posts:  8
Joined:  2009-07-21
Cagnes sur mer - Alpes Maritimes - France
 

Instead of changing query time, you could change

protected $_logAllQueries       false;

to

protected $_logAllQueries       true;

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top