Support ⇒ Requests :: Archives ⇒ [approved] Individual query times :: Archived ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexRequests

Archived ⇒ [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:
$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:
$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:
var $querytime = 0;

Then, change lines 40-44 of includes/db/db.php from:
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:
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:
$this->query($query, $bypass_error, $unbufferd);

add the following:
$this->querytime = get_microtime();

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


*core feature!* that would be nice

Please enter your server specs in your user profile! 😢


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.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/1.3.33/4.4/4.3.11


I know this will come in handy, bookmark me thinks!! Very Happy

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
XP / 2.0 / 5.1 / 5.2 / none


Nice Core Hack, i been looking for that a long time to add Queries Time in SQL Debug.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Apache/1.3.34 (Unix)/4.0.25-standard/4.4.1/CVS


Stickied as a core reference - CVS updated.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Ubuntu/Apache 2.2.22/MySQL 5.6.34/PHP 7.1.22/DragonFly 10.0.48.9418


This is awesome. Thank you much!

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


spacebar wrote
This is awesome. Thank you much!
AWESOME addition biggles!

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

All times are UTC
This forum is locked: you cannot post, reply to, or edit topics. Forum IndexRequests
Page 1 of 1