Print Thread
Hop To
#166834 10/22/2006 12:42 PM
Joined: Jun 2006
Posts: 9,242
Likes: 1
R
Former Developer
Former Developer
R Offline
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.
Rick #166835 10/22/2006 12:53 PM
Joined: Jun 2006
Posts: 3,837
I
Ian Offline
Carpal Tunnel
Carpal Tunnel
I Offline
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.

Ian #166837 10/22/2006 1:08 PM
Joined: Jun 2006
Posts: 9,242
Likes: 1
R
Former Developer
Former Developer
R Offline
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
I
Ian Offline
Carpal Tunnel
Carpal Tunnel
I Offline
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?

Ian #166840 10/22/2006 2:04 PM
Joined: Jun 2006
Posts: 9,242
Likes: 1
R
Former Developer
Former Developer
R Offline
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 wink 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
M
enthusiast
enthusiast
M Offline
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.


##eek##
Joined: Jun 2006
Posts: 9,242
Likes: 1
R
Former Developer
Former Developer
R Offline
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
M
enthusiast
enthusiast
M Offline
Joined: Jun 2006
Posts: 162
Ah, I see. So you would just loose a few counts, that's fine for me.


##eek##
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
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,300
Likes: 116
My opinion; a temporary table is a temporary table wink...


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Aug 2006
Posts: 1,649
Likes: 1
Pooh-Bah
Pooh-Bah
Joined: Aug 2006
Posts: 1,649
Likes: 1
Originally Posted by Rick
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. wink


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


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Version 7.7.5 Images suddenly not displaying
by Stovebolt - 05/04/2024 11:19 AM
Bots
by Outdoorking - 04/13/2024 5:08 PM
Can you add html to language files?
by Baldeagle - 04/07/2024 2:41 PM
Do I need to rebuild my database?
by Baldeagle - 04/07/2024 2:58 AM
This is not a bug, but a suggestion
by Baldeagle - 04/05/2024 11:25 PM
Who's Online Now
1 members (1 invisible), 939 guests, and 146 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240501)