MyBB Community Forums

Full Version: [Tutorial] Save up to 10% of your database.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
With Hackforums.net at 1.1gb of space I am always looking for ways to minimize that.

My mybb_posts table was 880mb alone with 1.2 million posts. Looking at the table there is the "subject" column. In a reply this is often now used and MyBB automatically places the actual thread subject inside this area. It's also apparently not required if you decide to make it blank and post a reply.

So I started with removing it completely from the postbit and reply template along with the posticon code in reply.

Remove from postbit and postbit classic:

				<span class="smalltext"><strong>{$post['icon']}{$post['subject']} {$post['subject_extra']}</strong></span>

Remove from newreply
<tr>
<td class="trow2" width="20%"><strong>{$lang->post_subject}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
{$posticons}

This should not harm your site at all. Next I decided to take it one step further and delete existing subjects in the column from replies and I ran this in phpmyadmin.

UPDATE mybb_posts SET subject="" WHERE replyto != "0";

Remember to optimize your tables when you are done as it may delete lots of space and it will only reflect this after you optimize.

On my site my mybb_posts table went from 880mb to 730mb. That's significant.

Thank you.
Very awesome. I'm not to concerned about space but I particularly hate the idea of having a subject field for replies... the subject should only be for the original post! Big Grin
Okay found a problem.

Supposedly MyBB does require that a subject be there. If you quick reply then it does a subject of the thread plus "RE:" which we so often see. If you do a full reply you can reply but it will fill in the same info if it's blank. If you do a full reply and try a preview you get a No Subject error message.

To me this is not acceptable. A reply should not require a subject.

I have begun to find out what I have to change to prevent the error.

Inside inc/datahandlers/post.php there are two lines I had to comment out.

			elseif(my_strlen($subject) == 0)
			{
				$thread = get_thread($post['tid']);
//				$subject = "RE: ".$thread['subject'];
			}
		}

		// This is a new post
		else if($this->action == "post")
		{
			if(my_strlen($subject) == 0)
			{
				$thread = get_thread($post['tid']);
//				$subject = "RE: ".$thread['subject'];
			}
		}

I will report back my findings but again...I am not too happy about a reply subject being required and automatically entered into database. I see no reason for it.
Why not replace:
<tr>
<td class="trow2" width="20%"><strong>{$lang->post_subject}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
{$posticons}

With:
<input type="hidden" name="subject" value="RE:"/>
?
Hmm...that's a maybe. I might actually just place it as one character though.

Also that won't help quick reply I don't think.

From what I see there are 3 more lines I have to comment out inside newreply.php.

This is twice in the file:
		"subject" => $mybb->input['subject'],

Then this as well:
		$valid_subject = $posthandler->verify_subject();

Oh how I really hate core file edits but it's apparently come to this to optimize my site.


=========================

EDIT: Grr...I have opted to use your method Kujoe to avoid the core file edits. I am probably going to just use a ? as the single reply character. Thanks for assistance.

What's your opinion that this is required and automatically filled in?
Well I already voiced my opinion about subjects for all posts not being the original post but I agree that subjects shouldn't be required. And personally, after making the template changes I personally think it makes the threads look better without the subjects for each post. I tested it with quick replies and regular replies without any issues (including the Preview). I opted for RE: because that's usually the default for other forum software I've used so I figured it was better than including the whole subject.

Lastly, I can confirm it does save almost 10% of disk space regardless of database size. Big Grin
(2009-09-10, 11:19 PM)labrocca Wrote: [ -> ]Looking at the table there is the "subject" column. In a reply this is often now used and MyBB automatically places the actual thread subject inside this area. It's also apparently not required if you decide to make it blank and post a reply.

It's main function is in the threaded display. For example, a normal thread will look like this:
  • [Tutorial] Save up to 10% of your database - Labrocca
    • RE: [Tutorial] Save up to 10% of your database - KuJoe
      • RE: [Tutorial] Save up to 10% of your database - Labrocca
What you're proposing will take it to:
  • [Tutorial] Save up to 10% of your database - Labrocca
    • ? - KuJoe
      • ? - Labrocca
As a suggestion, replace ? with a simple "Replied". Or, just remove the threaded display link in the thread header if you don't plan on using it Toungue.

Shy
Oh jeez...threaded replies. I still don't understand why that still exists for MyBB. They got rid of the favorite threads in 1.4x but kept threaded view. I never understood that. Anyone that wants to run threaded view would probably use something like Vanilla. Show me some MyBB forums using threaded and maybe I will change my mind about it's usefulness. I have yet to see one.

I am going to remove the threaded view link too.
A few use threaded mode but I really can't see any benefit in only having one post showing at a time and having to click to view each one, you can't skim read the thread to find anything.
I am thinking to place the "Subscribe to this thread" link on the top to replace that linear/threaded mode. Hmm..imho that's a more appropriate place for it.
Pages: 1 2