Tag Archives: SQL

Want to dump every SQL query Magento runs?

In: lib/Zend/DB/Adapter/Adapter.php

public function query($sql, $bind = array())
    {
        // connect to the database if needed
        $this->_connect();

        // is the $sql a Zend_Db_Select object?
        if ($sql instanceof Zend_Db_Select) {
            if (empty($bind)) {
                $bind = $sql->getBind();
            }

            $sql = $sql->assemble();
        }
        $time_start = microtime(true);

        // make sure $bind to an array;
        // don't use (array) typecasting because
        // because $bind may be a Zend_Db_Expr object
        if (!is_array($bind)) {
            $bind = array($bind);
        }

        // prepare and execute the statement with profiling
        $stmt = $this->prepare($sql);
        $stmt->execute($bind);

        // return the results embedded in the prepared statement object
        $stmt->setFetchMode($this->_fetchMode);

        $time_end = microtime(true);
        $time = $time_end - $time_start;

        echo "SQL[$time | $sql ]" . "\n<br />\n";
        return $stmt;
    }

How fuc**d is your database?

Are you using PostgreSQL, MySQL, MSSQL, Oracle, SQLite, MS Access, or NoSQL?

http://howfuckedismydatabase.com/

Performance Optimization WordPress Plugins by W3 EDGE