| Topic Archived |
View previous topic :: View next topic |
| Author |
Message |
Biggles Debugger


Offline Joined: Aug 03, 2005 Posts: 637 Location: St. Louis, MO
|
Posted: Fri Mar 24, 2006 7:54 am Post subject: [approved] Individual query times |
|
While optimizing some queries for the website I administer I thought it would be handy to know the query time of each query rather than all of them summed so I could spot the slow ones more easily. For mysql 4.0 on Dragonfly 9.0.6.1, change lines 52-53 of your includes/db/mysql.php file from:
| PHP: |
$this->query_result = ($unbufferd) ? mysql_unbuffered_query($query, $this->connect_id) : mysql_query($query, $this->connect_id); if (CPG_DEBUG || is_admin()) $this->querylist[$this->file][] = '<b>LINE '.$this->line.':</b> '.htmlprepare($query);
|
to:
| Code:: |
$stime = get_microtime();
$this->query_result = ($unbufferd) ? mysql_unbuffered_query($query, $this->connect_id) : mysql_query($query, $this->connect_id);
if (CPG_DEBUG || is_admin()) $this->querylist[$this->file][] = '<b>'.round((get_microtime()-$stime), 4).' seconds - LINE '.$this->line.':</b> '.htmlprepare($query);
|
For 9.1.0.8 it's a little easier, add the following after line 30 of includes/db/db.php:
Then, change lines 40-44 of includes/db/db.php from:
| PHP: |
if ($failed) { $this->querylist[$this->file][] = '<b style="font-color: #f00">FAILED LINE '.$this->line.':</b> '.htmlprepare($query); } else { $this->querylist[$this->file][] = '<b>LINE '.$this->line.':</b> '.htmlprepare($query); }
|
to:
| Code:: |
if ($failed) {
$this->querylist[$this->file][] = '<b style="font-color: #f00">'.round((get_microtime()-$this->querytime), 4).' seconds - FAILED LINE '.$this->line.':</b> '.htmlprepare($query);
} else {
$this->querylist[$this->file][] = '<b>'.round((get_microtime()-$this->querytime), 4).' seconds - LINE '.$this->line.':</b> '.htmlprepare($query);
}
|
Finally, before line 143 of includes/db/db.php:
| PHP: |
$this->query($query, $bypass_error, $unbufferd);
|
add the following:
| PHP: |
$this->querytime = get_microtime();
|
Biggles's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Win, Linux/1.3.34/4.0.26, 5.0.19/4.3.10, 5.1.2, 8.1.4(PostgresSQL)/9.0.6.1, CVS
|
|
| Back to top |
|
 |
Head-e Silver Supporter


Offline Joined: Apr 20, 2004 Posts: 937
|
Posted: Fri Mar 24, 2006 8:03 am Post subject: Re: Individual query times |
|
*core feature!* that would be nice
Head-e please enter your server specs in your user profile!
|
|
| Back to top |
|
 |
djdevon3 Gold Supporter


Offline Joined: Aug 05, 2004 Posts: 4363
|
Posted: Fri Mar 24, 2006 12:56 pm Post subject: Re: Individual query times |
|
Geez Biggles you really tore into that one. Nice work. I hope it goes in as an admin option for cvs. Thanks for sharing it.
djdevon3's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux/1.3.33/4.4/4.3.11
|
|
| Back to top |
|
 |
t31os Supporter


Offline Joined: Sep 22, 2004 Posts: 2025 Location: Somewhere in the intertubes... lolz
|
Posted: Fri Mar 24, 2006 4:44 pm Post subject: Re: Individual query times |
|
I know this will come in handy, bookmark me thinks!!
t31os's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) XP / 2.0 / 5.1 / 5.2 / none
|
|
| Back to top |
|
 |
xfsunoles XHTML Specialist


Offline Joined: Apr 30, 2004 Posts: 2502 Location: Melbourne, Florida
|
Posted: Fri Mar 24, 2006 4:54 pm Post subject: Re: Individual query times |
|
Nice Core Hack, i been looking for that a long time to add Queries Time in SQL Debug.
xfsunoles's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Apache/1.3.34 (Unix)/4.0.25-standard/4.4.1/CVS
|
|
| Back to top |
|
 |
Phoenix • Many Posts •


Offline Joined: Apr 19, 2004 Posts: 8799 Location: Netizen
|
Posted: Wed Aug 30, 2006 11:40 am Post subject: Re: Individual query times |
|
Stickied as a core reference - CVS updated.
_________________ • DonationsPro for DragonflyCMS, SMF, MyBB, vBulletin •
Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
|
|
| Back to top |
|
 |
spacebar Dragonfly addicted


Offline Joined: Sep 28, 2005 Posts: 413 Location: Providence
|
Posted: Wed Aug 30, 2006 2:29 pm Post subject: Re: Individual query times |
|
This is awesome. Thank you much!
_________________

spacebar's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1
|
|
| Back to top |
|
 |
caladrius Nice poster


Offline Joined: Jan 25, 2006 Posts: 108
|
Posted: Wed Aug 30, 2006 2:38 pm Post subject: Re: Individual query times |
|
| spacebar wrote: |
| This is awesome. Thank you much! |
AWESOME addition biggles!
caladrius's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.4.27-2-686/Apache 1.3.34/5.0.19-Debian_2/4.4.2/Dragonfly 9.0.6.1
|
|
| Back to top |
|
 |
|
|