Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Oldiesmann on April 07, 2004, 12:11:53 PM

Title: Number of Queries in "Page created in..." string
Post by: Oldiesmann on April 07, 2004, 12:11:53 PM
I noticed something interesting earlier while comparing the speed of SMF to another forum system that prides themselves on speed. When you load the same page on an SMF board multiple times, the number of queries used to create that page tends to vary. For example, when loading the boardindex on this board twice in a 30 second period, one time it said it used 9 queries, and the next time it said it used 7 queries. Just curious as to what would cause this.
Title: Re: Number of Queries in "Page created in..." string
Post by: Chris Cromer on April 07, 2004, 12:18:06 PM
Because some queries don't have to be run all the time.

For instance whenever there is a new record for the ammount of people online at 1 time it will add 1 more query to update the info.

Also some queries are only run based on how much time has passed. That means that the query won't be run again until the ammount of times has passed. An example of this might be updating the online list, for instance it could be set to only update your last online time every 15 minutes to save from running a query every click.
Title: Re: Number of Queries in "Page created in..." string
Post by: [Unknown] on April 07, 2004, 12:28:43 PM
Which is very important for speed, because when you do redirecting (example: posting!) a lot, which all forums do, you end up hitting the database with WRITE queries TWICE as often as neccessary, which is veyr bad for MySQL 4 query caching.

So if you see a forum that DOESN'T vary, and pretends it's fast, it could still be faster.

-[Unknown]
Title: Re: Number of Queries in "Page created in..." string
Post by: Oldiesmann on April 08, 2004, 01:33:40 PM
Cool. I figured it was something like that.
Title: Re: Number of Queries in "Page created in..." string
Post by: Homie on April 08, 2004, 07:09:11 PM
What Are Queires
Title: Re: Number of Queries in "Page created in..." string
Post by: Grudge on April 08, 2004, 07:10:30 PM
A query is used everytime information is retrieved from the database
Title: Re: Number of Queries in "Page created in..." string
Post by: Chris Cromer on April 08, 2004, 07:11:30 PM
Part true, but a query is also used when inserting and updating as well. ;)
Title: Re: Number of Queries in "Page created in..." string
Post by: Grudge on April 08, 2004, 07:14:21 PM
and optimising, creating tables etc etc :P

Don't be so picky :D
Title: Re: Number of Queries in "Page created in..." string
Post by: Homie on April 08, 2004, 07:16:57 PM
Thanks  :)
Title: Re: Number of Queries in "Page created in..." string
Post by: [Unknown] on April 08, 2004, 07:18:52 PM
A query is literally when the PHP queries, or asks, the MySQL server a question.  This question could be:

Will you insert this for me?

Or....

What is the time now?

Or even:

Can you optimize this table, please?

What's more... MySQL can say no :P.

-[Unknown]
Title: Re: Number of Queries in "Page created in..." string
Post by: Homie on April 08, 2004, 07:21:20 PM
Thanks [Unkown] you are the best at explaining stuff  :)
Title: Re: Number of Queries in "Page created in..." string
Post by: Grudge on April 08, 2004, 07:23:57 PM
[Unkown] may explain stuff better but at least my name is easier to spell :P
Title: Re: Number of Queries in "Page created in..." string
Post by: Chris Cromer on April 08, 2004, 07:27:35 PM
Actually I had a hard time remembering if it was d before g or g before d. :P

Although I have been up 2 days in a row... so my brain is just toast right now. :P
Title: Re: Number of Queries in "Page created in..." string
Post by: [Unknown] on April 08, 2004, 07:34:39 PM
LOL.  That's all I have to say.  To both of you, Grugde and Chris Should-Be-Sleeping. (I do that myself a lot)

-[Unknown]
Title: Re: Number of Queries in "Page created in..." string
Post by: Chris Cromer on April 08, 2004, 07:38:17 PM
Well it's 6PM here right now... I am waiting till about 9 before I go to bed so that I can wake up at a decent hour. I had been waking up at like 10PM and going to sleep durning the day(my whole family does... they work night shifts)... but I am trying to get back to normal.

I have 3 hours to kill... and nothing to do...
Title: Re: Number of Queries in "Page created in..." string
Post by: [Unknown] on April 08, 2004, 07:40:23 PM
Work on the mod site! :P

-[Unknown]
Title: Re: Number of Queries in "Page created in..." string
Post by: Chris Cromer on April 08, 2004, 07:44:56 PM
Would you trust me coding that in my current state of mind?

Besides, I havn't even looked at the backend of the mod site yet. :P