Home Private Messages Search
CPG Dragonfly™ CMS Dedicated Server & Bandwidth Sponsored by DedicatedNOW
Toggle Content
 
Forums ⇒ CMS (All) ⇒ Requests :: Archives ⇒ [approved] Individual query times :: Archived


[approved] Individual query times :: Archived
Requests for core changes must be submitted through the Projects Features section.
This forum is locked: you cannot post, reply to, or edit topics.    This topic is locked: you cannot edit posts or make replies.    Printer Friendly Page     Forum Index ⇒  Requests

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

Offline Offline
Joined: Aug 03, 2005
Posts: 637
Location: St. Louis, MO
PostPosted: 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:
PHP:
var $querytime = 0;

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
View user's profile Visit poster's website ICQ Number AIM Address MSN Messenger Yahoo Messenger
Head-e
Silver Supporter
Silver Supporter

Offline Offline
Joined: Apr 20, 2004
Posts: 937

PostPosted: 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! Crying or Very sad
Back to top
View user's profile Photo Gallery
djdevon3
Gold Supporter
Gold Supporter

Offline Offline
Joined: Aug 05, 2004
Posts: 4363

PostPosted: 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
View user's profile Visit poster's website Photo Gallery
t31os
Supporter
Supporter

Offline Offline
Joined: Sep 22, 2004
Posts: 2025
Location: Somewhere in the intertubes... lolz
PostPosted: Fri Mar 24, 2006 4:44 pm
Post subject: Re: Individual query times

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


t31os's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
XP / 2.0 / 5.1 / 5.2 / none
Back to top
View user's profile Visit poster's website
xfsunoles
XHTML Specialist
XHTML Specialist

Offline Offline
Joined: Apr 30, 2004
Posts: 2502
Location: Melbourne, Florida
PostPosted: 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
View user's profile Visit poster's website AIM Address MSN Messenger Yahoo Messenger Photo Gallery
Phoenix
• Many Posts •
• Many Posts •

Offline Offline
Joined: Apr 19, 2004
Posts: 8799
Location: Netizen
PostPosted: 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
View user's profile Visit poster's website Photo Gallery
spacebar
Dragonfly addicted
Dragonfly addicted

Offline Offline
Joined: Sep 28, 2005
Posts: 413
Location: Providence
PostPosted: 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
View user's profile Visit poster's website ICQ Number AIM Address MSN Messenger Yahoo Messenger
caladrius
Nice poster
Nice poster

Offline Offline
Joined: Jan 25, 2006
Posts: 108

PostPosted: 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
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.    This topic is locked: you cannot edit posts or make replies.    Printer Friendly Page    Forum Index ⇒  Requests
Page 1 of 1
All times are GMT

Archive Revive
Username:
This is an archived topic - your reply will not be appended here.
Instead, a new topic will be generated in the active forum.
The new topic will provide a reference link to this archived topic.
 
   Toggle Content User Info

Welcome Anonymous

Nickname
Password
(Register)

   Toggle Content Last CVS commits
· Fixed .ico Expires header.
· Removed domain name from cookies so subdomains wont access them anymore.
· CSS and JS, case insensitives.
· CSS and JS, send correct HTTP 1.1 headers and fixed issues where themes and...
· Further security class improvements.
· 301 redirects on LEO changes
· Option to force 3xx http status codes
· Validate googlebot.com and google.com crawlers.
· CCBot
· Rss with etag and atom.

lexo me teper

   Toggle Content Community

Support for DragonflyCMS in a other languages:

Deutsch
Español

   Toggle Content X-links
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy