Jump to content

One Table vs Two Tables


neoform

Recommended Posts

I'm making a messaging system that has the fields:

 

id INT(10)
posted_on DATETIME (INDEX)
user_id MEDIUMINT( (INDEX)
recipient_user_id MEDIUMINT( (INDEX)
body TEXT

 

I've been torn as to whether or not I should split the body field into a second table in order to speed things up. I ran some tests with SELECTs and found that using a single table is usually between 20% to 100% faster (depending on how many rows are being selected and if the body is included in the SELECT).

 

Where the single table is slower though, is on INSERT, UPDATE and DELETE, because of the reindexing of the DYNAMIC table (single table) vs the FIXED table (two table)..

 

So the question is, which is the better option, assuming I'm actually going to fill this table up with more than a million rows.

 

BTW, the tests I did were on tables with 300,000 rows packed with identical random data.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.