News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Approx. 132 Queries when viewing topics...

Started by SoLoGHoST, October 14, 2009, 05:10:11 PM

Previous topic - Next topic

SoLoGHoST

Just coded a mod, and well, looking at the amount of database hits, should I be concerned.  I know SMF's default queries when viewing topics is approx. 13, so the rest have been all me :( :(  I have tried several attempts to optimize it so it uses less queries when viewing topics (all message in a topic), but it usually ranges from 50 - 132 with my mod installed.  I'm wondering if this is a problem for big servers??  The queries are small and simple, but just wondering how it will stack up to about 500 people viewing the same topic at once...

The problem is, it calls a query upon each message in the topic.  May need to just call it once, get all info, and throw it in an array of data...

Any ideas on this anyone??

tadpole

1) You should be very concerned.  That's 10 times the normal amount of queries - so, with even just a moderate amount of activity, you risk overloading the server.

2) What does this mod do, and what queries are you running over and over again?  If we knew what they did / were, we'd probably be able to help you consolidate queries.

Arantor

:o

A query per message per topic?

I have to ask, what is this doing?
Holder of controversial views, all of which my own.


SoLoGHoST

Post Ratings MOD.  You can Rate Posts from 1 - 5 Stars.  You can see it working over here => http://acs.graphicsmayhem.com/newforum/index.php

Database debug info is on, so you can see how many db hits when viewing topics, at the bottom.

Arantor

Where's that being held? Best bet otherwise would be to do a JOIN and GROUP on the relevant columns.
Holder of controversial views, all of which my own.


SoLoGHoST


Arantor

To be honest, seeing the DB structure would probably be more useful if that's OK?
Holder of controversial views, all of which my own.


SoLoGHoST

Ok, I'm going to have a crack at it.  I know I can do this as it's all just the same columns that are being used when calling the queries, and a few other columns.  Will give it a go, if I run into a problem, will post up in here.  Thanks again Arantor :)

SoLoGHoST

OK, OK, I did it, I am the MAN!!  Down to 20 Queries.  In the process of it, I have learned just about everything there is to know about SMF displaying messages in topics now...lol.  So was definitely worth it to do it myself.  Thanks for the offer Arantor, will have to take a raincheck on it until next time ;)

Arantor

20 queries is still too much IMO depending on what you're doing. (We do consider performance as part of mod review, btw)
Holder of controversial views, all of which my own.


SoLoGHoST

No, it's 20 queries altogether with attachments.  It is far less without attachments.  My mod only uses approx. 3 - 5 queries per topic page.

Arantor

Oh, 20 queries for the entire page is OK generally, but we'll still take a look at it upon submission.
Holder of controversial views, all of which my own.


SoLoGHoST

I know you will.  Going to see if I can tweak it more though ;)  Still have to clean it up a little and fix a few minor problems with it before it's ready for submission.  And then there's the waiting until RC2 comes out bit, since the integers in the columns need to be unsigned, so I have to use the old database functions for this instead.  So I already know it won't be approved until I convert it over to RC2.

Well, anyways, Cheers and Goodnight :)

Advertisement: