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
https://forums.phpfreaks.com/topic/104592-one-table-vs-two-tables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.