Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Display # of database queries?
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 14 March 2002 :  20:22:15  Show Profile
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  Show Profile
What about just adding a line intQueryCount = intQueryCount + 1 after each SQL statement execution?

Nikkol
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 14 March 2002 :  20:40:00  Show Profile
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.
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 14 March 2002 :  20:50:13  Show Profile  Visit Gremlin's Homepage
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
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 14 March 2002 :  20:54:49  Show Profile
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
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 14 March 2002 :  21:02:28  Show Profile  Visit Nathan's Homepage
ExecuteComplete: http://www.devguru.com/Technologies/ado/quickref/connection_executecomplete.html

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 14 March 2002 :  21:06:31  Show Profile  Visit Gremlin's Homepage
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
Go to Top of Page

nomad_2k
Junior Member

United Kingdom
173 Posts

Posted - 16 March 2002 :  14:59:01  Show Profile
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

Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 16 March 2002 :  16:51:47  Show Profile  Visit Gremlin's Homepage
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
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 03 April 2002 :  20:12:54  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
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.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 April 2002 :  20:18:16  Show Profile  Visit HuwR's Homepage
Any advantages of doing it at all, seems like a lot of extra function calls for no reason.

Go to Top of Page

snaayk
Senior Member

USA
1061 Posts

Posted - 03 April 2002 :  20:21:46  Show Profile  Visit snaayk's Homepage  Send snaayk an AOL message  Send snaayk an ICQ Message  Send snaayk a Yahoo! Message
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!!

Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 03 April 2002 :  20:24:12  Show Profile
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.
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 03 April 2002 :  20:25:26  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 03 April 2002 :  20:27:44  Show Profile  Visit Gremlin's Homepage
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 April 2002 :  20:28:59  Show Profile  Visit HuwR's Homepage
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.

Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.36 seconds. Powered By: Snitz Forums 2000 Version 3.4.07