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

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MySql
 Want a faster forum?
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

Ocean
Starting Member

5 Posts

Posted - 07 February 2008 :  18:56:24  Show Profile
Please excuse me if someone has already posted this!

While fiddling with the code and learning about caching on MySQL (should also apply to other DB's), we identified a 4 character change than will half the disk access of your database.

In forums.asp

defDate = DateToStr(dateadd("d",-(nDays),strForumTimeAdjust)),8)

Change to

defDate = Left(DateToStr(dateadd("d",-(nDays),strForumTimeAdjust)),8) & "0000"

All it does it trim the hours/minutes off and default them to midnight.

For each user, it was generating a unique SQL statement which the DB engine cannot cache:
SELECT ___ WHERE T_LAST_POST > '200801021233'
SELECT ___ WHERE T_LAST_POST > '200801021234'
SELECT ___ WHERE T_LAST_POST > '200801021236'
SELECT ___ WHERE T_LAST_POST > '200801021239'
etc...

after the change it becomes
SELECT ___ WHERE T_LAST_POST > '200801020000'
SELECT ___ WHERE T_LAST_POST > '200801020000'
SELECT ___ WHERE T_LAST_POST > '200801020000'
SELECT ___ WHERE T_LAST_POST > '200801020000'

..until a change of day.

It's more than good enough for the query to be accurate to the day, rather than to the minute.

As a result, MySQL caches the keys and the performance increase is very tidy!

Hope this is of some use to somebody and am not duplicating someone else.

Enjoy!



pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 07 February 2008 :  19:26:52  Show Profile  Send pdrg a Yahoo! Message
Interesting tip - have you got any stats for your speed increases? Are they noticeable?
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 08 February 2008 :  01:57:55  Show Profile  Visit HuwR's Homepage
however, this will completely change the behaviour of forum.asp so be warned


if your db has problems like this you should either look for a more enterprise level database like MS SQL or change the hardware that your MySQL db is running on, because if not caching a handful of queries makes that much difference then your server is sreiously under powered
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 08 February 2008 :  04:54:06  Show Profile  Visit MarcelG's Homepage
Huw, I'm not familiar with this piece of code ; what will change in terms of functionality when applying this change?

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 08 February 2008 :  05:21:22  Show Profile  Visit modifichicci's Homepage
Isn't affected the order of topics and reply? how can we see if a reply is posted before another as the difference is the hour?

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 08 February 2008 :  05:48:07  Show Profile  Visit AnonJr's Homepage
I was also wondering about the people that visit more than once a day... I just woke up and am eating breakfast now, but if the above changes were in place, and assuming I'm understanding this correctly before I've had my coffee (big assumption), would I not see this as a "new topic" (or at least as having had new posts) again when I come back on my lunch break later today regardless of it having any new posts?
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 08 February 2008 :  06:01:23  Show Profile  Send ruirib a Yahoo! Message
Well, the original code was there for a reason and the reason was to have a page that's customized for each user. Of course, the proposed changes do end that, so where this is a viable option or not depends on how you want the forum to behave. I wouldn't want this on a forum of mine.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 08 February 2008 :  06:10:41  Show Profile
That date is used to select how many days of topics you want to see on forum.asp.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 08 February 2008 :  07:23:05  Show Profile  Send ruirib a Yahoo! Message
Yeah, you're right, it's not really personalized.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 08 February 2008 :  07:51:29  Show Profile
The problem is, though, if someone has it set to show topics from the last day, there's not going to be much to see at a minute past midnight.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 08 February 2008 :  08:07:26  Show Profile  Send ruirib a Yahoo! Message
True... Also, what percentage of views does forum.asp get?


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 08 February 2008 :  08:50:58  Show Profile  Visit HuwR's Homepage
quote:
Originally posted by MarcelG

Huw, I'm not familiar with this piece of code ; what will change in terms of functionality when applying this change?



It will not return the same set of topics to forum.asp

I am not saying it is wrong, just that you should expect it to behave totally differently if you make the change. what you will in effect do is change it so that say for instace if you picked to view topics from 'the last day' what it does now is show you all topics posted in the last 24 hrs, if you make the change it will show you the topics posted since midnight yesterday which is not the same thing.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 08 February 2008 :  15:48:51  Show Profile  Visit AnonJr's Homepage
Ah, that makes sense. for some odd reason I missed the part about it being in forum.asp... guess that's what I get for posting before the first cup of coffee.
Go to Top of Page

Ocean
Starting Member

5 Posts

Posted - 11 February 2008 :  01:17:20  Show Profile
It works for us, and nobody has complained. We churn out around a million page views/month.

Our server runs faster, and our database cache hit ratio has tripled.

If you have a busy forum (>1,000,000 page views/month), and would like more performance for no dollars, be bold and make the change.

If everything is fine, then no change is necessary.

quote:
if your db has problems like this you should either look for a more enterprise level database like MS SQL


This comment intrigues me - HuwR I'd be really keen on seeing some stats in regards to this, for if what you say is true, we'd seriously investigate migration - thanks.

quote:
change the hardware that your MySQL db is running on, because if not caching a handful of queries makes that much difference then your server is sreiously under powered


Our server was starting to chug. A four character change has now avoided thousands of $ change over/upgrades. A key for us is remembering it's only a forum, not bank statements, and the definition of "Last 1 days" (which I don't think anybody even uses) is pretty open to interpretation.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 11 February 2008 :  01:57:25  Show Profile  Visit HuwR's Homepage
quote:
This comment intrigues me - HuwR I'd be really keen on seeing some stats in regards to this, for if what you say is true, we'd seriously investigate migration - thanks.
there are plenty of comparisons around which show that MSSQL is a more resiliant and powerful database than MySQL.

Like I said, if caching one query has such a profound effect on your databases performance then there is something not quite right about the spec of your database server.
Go to Top of Page

Ocean
Starting Member

5 Posts

Posted - 11 February 2008 :  05:13:58  Show Profile
Thanks for your comments guys - it's been an educational experience visiting here to share knowledge.

Hope you all have a fantastic day!
Go to Top of Page
Page: of 2 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.19 seconds. Powered By: Snitz Forums 2000 Version 3.4.07