views:

66

answers:

2

I recently joined a new company and the development team was in the progress of a project to rebuild the database categories structure as follows:

if we have category and subcategory for items, like food category and italian food category in food category. They were building a table for each category, instead of having one table and a link to the category id.

Now we have a table called food and another table called food_italian and both tables contain the same fields.

I have asked around and it seems that some DBA prefers this design. I would like to know why? and how this design can improve the performance?

+2  A: 

First, the most obvious answer is that you should ask them, not us, since I can tell you this, that design seems bogus deluxe.

The only reason I can come up with is that you have inexperienced DBA's that does not know how to performance-tune a database, and seems to think that a table with less rows will always vastly outperform a table with more rows.

With good indices, that need not be the case.

Lasse V. Karlsen
thank you for your reply, I have actually asked them obviously, but the answer didn't seem reasonable, that's why I am here.There answer was that by reducing the number of joining in tables we will gain performance when fetching rows.Since we have hundreds of thousands of visitors on the website performing posting and searching.The way I could think of is to have a category table with fk to itself to have unlimited depth for categories and then have another table with category meta in case we need to have more fields for some categories.they use phinx, we can use lucene for search.
Rima
The comment was over before i finish sorry - I wanted to say more that I am trying to collect some facts in DB performance to compare what I described in my previous comment with what the developers are doing. The issue that makes it more worthy to consider what they are doing is that another really big company DBA has decided to do the same on their databases .. I heard this news when I was digging it out. But I can't reach him to ask him why.Does it make sense that less joins will increase the performance?
Rima
Yes, less joins will increase performance, but partitioning the tables like this will be a maintenance nightmare. So it all comes down to what you focus on.
Lasse V. Karlsen
How far it can affect the performance? can I get numbers somewhere? the query time in ms for each of these designs
Rima
No, that depends on too many factors for anyone but a profiling tool running with your servers, your data, and your queries, to give you. I'm afraid there's no hard facts here. I can guarantee that it will be a maintenance nightmare though, especially if you later on decide that "Well, fruit from trees have a property that determines how high above the ground they grow, but fruit on bushes doesn't need that, so let's make the tables different in structure."
Lasse V. Karlsen
can't table views and stored routines enhance the performance the same amount the table partitioning does?I am very sure that they are more worry about the performance than the future maintenance :)
Rima
A: 

There are more than one way to do anything.

The possible benefit I see in doing the food, food_italian... is that it allows for table partitioning. Using many different tables allow for better table locking mechanism if you are using myisam.

Yada