PDA

View Full Version : In MySQL, does having too many columns make a difference when those...


yaaay
10-09-2007, 05:04 AM
...columns are not used? I have these two tables:

books_large(Title, ISBN, Author, useless_field1, useless_field2, ..., useless_field20)

books_small(Title, ISBN, Author)

They both have the same books (let's say, all the books from a given bookstore), but books_large has a lot of useless fields like "short_description", "number_of_pages" or "average_rating". My question is the following:

Does this query: "SELECT Title,ISBN,Author FROM my_table WHERE MATCH Title AGAINST ('some keywords')" perform better in books_small than in books_large?

Aren't databases built in a way that it doesn't make a difference? Please tell me what you know and tell me how sure you are about your answer. Thanks a lot.

Dude Detâ„¢
10-09-2007, 05:16 AM
MySQL will pull only the columns in your select statement, and any columns you reference in the join or the where statement. Any columns not referenced will never be pulled/accessed.

William V
10-09-2007, 05:16 AM
In any relational database management system (RDBMS) you should think about "normalization". This is the process of making sure your data is efficiently stored. "De-normalization" is a term we use to make sure your data is efficiently retrieved (based on actual use). One needs to find a balance between these two approaches. As I discuss in my latest book "Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)" (see www.betav.com) database design (as you seem to understand) is often more important than the design of the applications that fetch and manage the data as far as performance goes...

See http://en.wikipedia.org/wiki/Database_normalization for more information on normalization.