MySQL: Which is smaller, storing 2 sets of similar data in 1 table vs 2 tables (+indexes)? -


I was asked to optimize (size-wise) data system for a fixed site and I saw that they Set 2 set state data in the same table. These sets display products on search listings and visit product pages. Each row has a product ID, State Date, State County, and State Flag column. The flag column indicates whether it is a search list display or page visit state stats are stored per day and product IDs, state date (in conjunction with the product ID and state type in fact) and are indexed in the state county. .

I was wondering if it is better (size-wise) to store those two sets as separate tables or to keep them as one I think the part difference It will be flag palace (its 1 byte TINIINT) and indexed. I'm particularly interested in how the place taken by the index will change in Table 2 scenario. There are already a few millions of records in the table in the question.

I'll probably do some tests when I have more time, but I was thinking that someone has already challenged the same problem.

By "Compliance", I mean that their original data are the same

It seems your comments are really favorable.

Why is that so?

First of all, you can easily add more consistent concepts easily. For example, you can add a new value to the Flag column, add sales to search-list and product-page views.

Secondly, you can easily report on the combination of comments type if you separate these things into different tables, then you'll be doing Unions or Johns when you return them Want to meet

Third, when the indexing is done correctly, the bases are the same at the time of access.

Fourth, the difference in disk space usage is small. You should get indexed in any case.

Fifth, the difference in cost of disk space is trivial. You have several million lines, or in other words, a dozen or even gigabytes of the highest quality Amazon web services storage cost US $ 1.00 per gigabyte per year. is. This is less than the heat for your office, the day you restructure this content. Let it be.


Comments