Zend Framework

Wrong count of executed queries

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: N/A N/A
  • Resolution: Not an Issue
  • Affects Version/s: 1.5.2
  • Fix Version/s: 1.9.6
  • Component/s: Zend_Db_Profiler
  • Labels:
    None

Description

Set up a small benchmark to check performance between InnoDB and ARCHIVE storage engine of mysql. Used example from manual to output results. Here the results:

InnoDB
Executed: 15 queries in 0.59294509887695 seconds
 Average query length: 0.039529673258464 seconds
   Queries per second: 25.297451700689
 Longest query length: 0.28680014610291
        Longest query: SELECT * FROM history LIMIT 50000
ARCHIVE
Executed: 14 queries in 1.0089721679688 seconds
 Average query length: 0.072069440569196 seconds
   Queries per second: 13.875506623919
 Longest query length: 0.48813700675964
        Longest query: SELECT * FROM history_072008 LIMIT 50000

There you can see that the first result contains 15 queries, the second result only 14. There should be only 14, so I think this is because of an initial sql query that will be executed before the first application based query will be executed. So I am forced to execute one senseless query to get correct count of queries.

Activity

Hide
Jan Pieper added a comment -

Attached benchmark (archive_bench.php).

Show
Jan Pieper added a comment - Attached benchmark (archive_bench.php).
Hide
Jan Pieper added a comment -

Oh sorry, I´ve attached a file where I already "fixed" my results. Please ignore lines 13 and 14.

Show
Jan Pieper added a comment - Oh sorry, I´ve attached a file where I already "fixed" my results. Please ignore lines 13 and 14.
Hide
Mickael Perraud added a comment - - edited

If you invert your tables, it's the same.

The first count include the 'connect' query. This query is of course erased by your lines 13 & 14.

Try this to see:

foreach ($oProfiler->getQueryProfiles() as $oQuery)
    {
        if ($oQuery->getElapsedSecs() > $iLongestTime)
        {
            $iLongestTime  = $oQuery->getElapsedSecs();
            $iLongestQuery = $oQuery->getQuery();
        }
        echo $oQuery->getQuery() . "\n";
    }

My result with your code (on very small table):

Executed: 15 queries in 0.0053527355194092 seconds
 Average query length: 0.00035684903462728 seconds
   Queries per second: 2802.3054652354
 Longest query length: 0.0035429000854492
        Longest query: connect

             Executed: 14 queries in 2.0547692775726 seconds
 Average query length: 0.14676923411233 seconds
   Queries per second: 6.8134170355801
 Longest query length: 0.2819390296936
        Longest query: SELECT * FROM tableau_planning LIMIT 7500

Closed as 'not an issue'

Show
Mickael Perraud added a comment - - edited If you invert your tables, it's the same. The first count include the 'connect' query. This query is of course erased by your lines 13 & 14. Try this to see:
foreach ($oProfiler->getQueryProfiles() as $oQuery)
    {
        if ($oQuery->getElapsedSecs() > $iLongestTime)
        {
            $iLongestTime  = $oQuery->getElapsedSecs();
            $iLongestQuery = $oQuery->getQuery();
        }
        echo $oQuery->getQuery() . "\n";
    }
My result with your code (on very small table):
Executed: 15 queries in 0.0053527355194092 seconds
 Average query length: 0.00035684903462728 seconds
   Queries per second: 2802.3054652354
 Longest query length: 0.0035429000854492
        Longest query: connect

             Executed: 14 queries in 2.0547692775726 seconds
 Average query length: 0.14676923411233 seconds
   Queries per second: 6.8134170355801
 Longest query length: 0.2819390296936
        Longest query: SELECT * FROM tableau_planning LIMIT 7500
Closed as 'not an issue'

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: