Author |
Topic |
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 14 March 2002 : 20:22:15
|
Does anyone know how to display the total # of database queries that were performed on a given page?
Something like what phpBB2 does at the bottom of each of their pages?
http://area51.phpbb.com/phpBB2/index.php
It shows the # of queries executed.
this would need to be cross database compatible. Something in ADO maybe? |
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 14 March 2002 : 20:34:09
|
What about just adding a line intQueryCount = intQueryCount + 1 after each SQL statement execution?
Nikkol |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 14 March 2002 : 20:40:00
|
I was hoping to not have to do that. I was thinking that maybe the connection object would keep track of this? Probably not though. |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 14 March 2002 : 20:50:13
|
Well PHPbb uses a Database Abstraction Layer function called sql_query(), when that function is called the query counter is incremented then later displayed on the page footer.
So basically what Nikkol said is exactly how they do it.
www.daoc-halo.com |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 14 March 2002 : 20:54:49
|
There is a ExecuteComplete event in ADO, but I don't know how to use it.
Nevermind - VBScript doesn't support events.
Nikkol
Edited by - Nikkol on 14 March 2002 20:58:53 |
|
|
Nathan
Help Moderator
USA
7664 Posts |
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 14 March 2002 : 21:06:31
|
Ouch ... 708 occurences of my_conn in the forum files, it you were to add one extra line to count each query thats roughly how many I think you'd need to add in .
www.daoc-halo.com |
|
|
nomad_2k
Junior Member
United Kingdom
173 Posts |
Posted - 16 March 2002 : 14:59:01
|
Or you could replace all the my_Conn.Execute's with a function like this:
Function ExecuteSQL(ByVal SQLStatment) ExecuteSQL = my_Conn.Execute SQLStatment intQueryCount = intQueryCount + 1 End Function
|
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 16 March 2002 : 16:51:47
|
Yes, which would basically become the 'database abstraction layer' then.
It's still a truck load of work either way, those certainly quite a nice idea. I notice PHP now has gzip and other stuff included too going to have to look into a few of those features I think
www.daoc-halo.com |
|
|
Podge
Support Moderator
Ireland
3775 Posts |
Posted - 03 April 2002 : 20:12:54
|
Anybody do this for the latest version? I've done it for v3.1sr4 by simply incrementing a variable everytime after each SQL statement execution. Didn't take too long, about an hour for 200 odd occurrences.
Any advantages of doing it the function way ?
Podge ----------------------- www.thehungersite.com Click to donate free food. |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 April 2002 : 20:18:16
|
Any advantages of doing it at all, seems like a lot of extra function calls for no reason.
|
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 03 April 2002 : 20:21:46
|
This is definately a nice idea. More for myself as a *developer* (chuckles at the illusion created) than for visitors; do YOUR visitors really care about how many queries were executed? What's a query anyway? That will be the newest addition to the FAQ. Unless your site is a tech based one then it will be the uber cool script; "man how did you do that??"
I hope you all real developers get it to work, I'd use it just cuz its cool!!
|
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 03 April 2002 : 20:24:12
|
I just thought it would be useful with all of the talk lately about performance. If we knew exactly how many queries were used per page, we'd know what pages need to be worked on.
btw, Podge added it at the ForumCo. Support Forum here:
http://www.forumco.com/support/default.asp
default.asp uses quite a few queries, as does active.asp. |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 03 April 2002 : 20:25:26
|
Doh! I got double-beaten
Yes, it helps the developers and module writers keep track of how many queries are being executed so that they can optimize their code.
How many extra clockcycles does it take to call a function?
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's
Edited by - Nathan on 03 April 2002 20:27:01 |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 03 April 2002 : 20:27:44
|
If you want help identifying areas where theres maybe excessive DB calls, those of us running sqlserver can help out by using profiler to test each page, I'd be more than willing to help spend a little time with either 3.3 or the upcomming release just going through looking for potential problems.
www.daoc-halo.com |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 April 2002 : 20:28:59
|
when you are calling several hundred on a page, quite afew. When developing it is easy to do this ifyou use SQL, just open SQL profiler and open a page it will count and display all the queeries.
I just don't see the point of trying to optimise performance if you are going to add several hundred function calls to a page.
|
|
|
Topic |
|