0

I'm having a little trouble getting Aoe Profiler to create the database tables. I sometimes convert to mysql install scripts so I use use them to create the tables through the SQL query in phpMyAdmin. But this script I don't know how:

$this->startSetup();

$this->getConnection()->dropTable($this->getTable('aoe_profiler/run'));

/**
 * Create table 'aoe_profiler/profile'
 */
$table = $this->getConnection()
    ->newTable($this->getTable('aoe_profiler/run'))
    ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity' => true,
        'unsigned' => true,
        'nullable' => false,
        'primary' => true,
    ), 'Profile Id')
    ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), 'Creation time')
    ->addColumn('stack_data', Varien_Db_Ddl_Table::TYPE_VARBINARY, Varien_Db_Ddl_Table::MAX_VARBINARY_SIZE, array(), 'Data')
    ->addColumn('route', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(), 'Route')
    ->addColumn('url', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(), 'Url')
    ->addColumn('session_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(), 'Session ID')
    ->addColumn('total_time', Varien_Db_Ddl_Table::TYPE_FLOAT, null, array(), 'Total Time in seconds')
    ->addColumn('total_memory', Varien_Db_Ddl_Table::TYPE_FLOAT, null, array(), 'Total Memory in MB');
$this->getConnection()->createTable($table);

$this->endSetup();

Can someone help me out on this?

2 Answers 2

0

You can create the table by knocking down the version number in the table core_resource in phpMyAdmin. When you have the table in PMA, search for the module setup in the column code. Then in the column version, edit the version corresponding to the setup file. For example, if the current version is 0.0.3, and the setup script is upgrade-0.0.2-0.0.3.php, then you need to edit the version value to 0.0.2. After, you just refresh the cache in the admin. The table should be created. If the current version value is 0.0.4, you will need to change the config.xml of the module to 0.0.3 first before continue the above steps. After the table is created, you can restore the version back to 0.0.4 in the table and the config file.

0

Try this:

Open the file lib/Varien/Db/Adapter/Pdo/Mysql.php in your favorite text editor. Down around line 86, you’ll see the following class variables:

/**
  * Write SQL debug data to file
  *
  * @var bool
  */
 protected $_debug               = false;
 /**
  * Minimum query duration time to be logged
  *
  * @var unknown_type
  */
 protected $_logQueryTime        = 0.05;
 /**
  * Log all queries (ignored minimum query duration time)
  *
  * @var bool
  */
 protected $_logAllQueries       = false;
 /**
  * Add to log call stack data (backtrace)
  *
  * @var bool
  */
 protected $_logCallStack        = false;
 /**
  * Path to SQL debug data log
  *
  * @var string
  */
 protected $_debugFile           = 'var/debug/sql.txt';

The documentation does a good job of explaining what these variables do, but I’ll go through them anyway.

protected $_debug               = false;

– This is the switch that turns SQL debugging on or off. Set it to “true” to enable.

protected $_logQueryTime        = 0.05;

– This sets the minimum time in seconds that will determine which queries get logged. This is useful for finding slow queries that could be impacting your store’s performance. 0.05 seconds is a bit low. I recommend setting it to 1.0 seconds if you want to find the really slow queries.

protected $_logAllQueries       = false;

– This variable tells Magento to ignore the previous option and just log everything. Magento does a lot of database work, so turning this option on will generate a great deal of data. If you just want to get a general sense of the database operations going on when loading a specific page, you can enable this option by setting it to “true”.

protected $_logCallStack        = false;

– This option is helpful when debugging custom and third-party modules because in addition to the queries, it logs a backtrace of the methods that called the query. Again, if you’ve turned on the option to log all queries, this option will produce even more data to sift through.

protected $_debugFile           = 'var/debug/sql.txt';

– Finally, you have the option to set the location of the debug file, which is set to (your Magento root)/var/debug/sql.txt by default.

If you decide to enable this feature to debug your Magento store, make sure that you limit access your website by editing the appropriate section of your .htaccess file. Otherwise you will get a mix of queries from users browsing your site.

Also, make sure you remember to turn debugging off once you’re finished troubleshooting, or else the size of this log file will become a problem in itself. Hopefully this will help you to figure out that elusive bit of database latency slowing down your site.

1
  • Both answers are great but while waiting I did it a different way. I installed a fresh Magento then installed Aoe Profiler. Then I exported the Aoe table from the fresh install then imported it back into my database. It worked but I found other problems with Aoe Profiler that others also were having. So I tried to uninstall it ...still had issues so I rolled back my database to the previous day's version. Now my speed issue (adding to cart) seems to have gone. If I have any issue similar I'll come back here and give these a try. Thanks!
    – Freejoy
    Aug 22, 2017 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.