简体   繁体   中英

Should I split a table which has big size data?

I'm using MySQL. I need to save contents of XML file to database. The size of file is usually less than 10k.

The table looks like this:

articles
-----------
id
date
writer
...
file_name
file_content (Text)
file_date

Does splitting the table improve performance when I select just date and writer ? Or is there any other reason to split this table?

This is called vertical partitioning.

Basically if your total data set is very large (say, larger than RAM), and most of your queries do not use the large file_content data, putting it in another table will make the main table much smaller, therefore much better cached in RAM, and much, much faster.

Of course retrieving the file_content will be a little slower, so it depends how often you use it.

I used this technique on a forum. I stored the posts text (bbcode parsed to HTML) in the main table, and the original posts (in bbcode) in another table. When displaying forum pages, only the main table is hit. The original post text is used only for editing posts. This divided the posts table size by 2 and avoided having to double the RAM on this server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM