|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
There are 2 tables that we use in UBB.threads that are pretty much just temporary tables, but they get accessed very frequently. These are ubbt_ONLINE and ubbt_TOPIC_VIEWS. I've chagned both of these to a memory (heap) type table here. This basically makes it so the table resides in memory and isn't written to disk, which should provide a bit of a performance increase. These 2 tables are also prone to corruption since they are accessed and updated so frequently since every update requires writing to disk. Changing these tables so they just store their data in memory should help in that area as well.
We may end up making this change a part of the original setup. It's an easy change, one that you can try yourself if interested by running the following SQL commands
alter table ubbt_ONLINE type=heap
alter table ubbt_TOPIC_VIEWS type=heap
Last edited by Rick; 10/22/2006 7:11 PM.
|
|
|
|
Joined: Jun 2006
Posts: 3,837
Carpal Tunnel
|
Carpal Tunnel
Joined: Jun 2006
Posts: 3,837 |
Is there any minimum MySQL version for this - or server memory required. Is there a point where writing to the disk is better on bigger busier forums, or doesn't it matter?
Thanks.
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
No minimum version, heap tables have been around since vesion 3 of MySQL. There are limitations to the tables in that they cannot hold text or blob fields. They also lose all of their data when mysql is shutdown, etc, so they are really only good on temporary tables.
Memory useage. Currently 200 rows in the online table is using about 2 megs of memory. On a busy site where you have 500 or 600 people online you'd probably be using about 5-6 megs of memory. The TOPIC_VIEWS table is very small since it just stores a topic id, so that one won't use much at all.
The busier your forum is the more improvement you'll probably see by making this change. For example the online table is written to every time someone access a page. Under the normal table type it has to write that to disk, under a memory type table it just changes in memory, that's it. So, smaller forums probably won't notice much of a difference but larger forums will.
|
|
|
|
Joined: Jun 2006
Posts: 3,837
Carpal Tunnel
|
Carpal Tunnel
Joined: Jun 2006
Posts: 3,837 |
Thanks - what happens to the topics views data in the even of MySQL restarting? Who's online will reset and that is fine - but isn't the topic views required?
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
topic views is just a temp table as well. We no longer update topic views live since this put locks on the posts table every time it was updated. So what we do is store these in a the topic_views table. Every time a new post is made we grab everything from this table and then update the view counter in the TOPICS table at the same time we're updating other fields, and clear everything out from the topic_views table. Hopefully that's as clear as mud But in essence, the topic_views table is strictly a temp table as well, so losing data in that table would only mean you miss a few views at the most.
|
|
|
|
Joined: Jun 2006
Posts: 162
enthusiast
|
enthusiast
Joined: Jun 2006
Posts: 162 |
A good idea!
But - If this is introduced there also should be a script that can be called to safely shut down your MySQL server. My db automatically restarts once a week, so I like to call such a script before, to flush the contents of the heap tables to the disk tables. At least we should take care of the topic views and write them to disk, because there can be thousands of views before a new post is added to a topic. Btw, the view count of all the older topics, where no new posts will be added anymore, will stay unchanged forever. One could use such a shutdown-script to write the views to disk manually or on a regular interval.
####
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
I need to clarify a bit. It doesn't have to be a new post to that individual topic. Any new post to any topic will update all of the view counters for every topic. We just update them all at once.
|
|
|
|
Joined: Jun 2006
Posts: 162
enthusiast
|
enthusiast
Joined: Jun 2006
Posts: 162 |
Ah, I see. So you would just loose a few counts, that's fine for me.
####
|
|
|
|
Joined: Jun 2006
Posts: 626
Addict
|
Addict
Joined: Jun 2006
Posts: 626 |
This will also solve the reocurrence of the ubbt_TOPICS_VIEWS problem that I had?
|
|
|
|
Joined: Jun 2006
Posts: 16,300 Likes: 116
|
Joined: Jun 2006
Posts: 16,300 Likes: 116 |
My opinion; a temporary table is a temporary table ...
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
alter table ubbt_ONLINE type=heap
alter table ubbt_TOPICS_VIEWS type=heap The second one should be TOPIC...at least I hope so, cuz that's what I changed it to after getting a "table not found" error.
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Jun 2006
Posts: 626
Addict
|
Addict
Joined: Jun 2006
Posts: 626 |
Yes, I also agree that the command should be alter table ubbt_TOPIC_VIEWS type=heap
|
|
|
|
Bots
by Outdoorking - 04/13/2024 5:08 PM
|
|
|
|
|
1 members (1 invisible),
939
guests, and
146
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
|
|