2

I am building a website on MySQL with php, and I have 400+ products in a table. I have three columns with comma separated values, each has 1-3 values separated by commas in each row. I was wondering if my db would be faster if I make separate tables for those three columns?

  • 3
    Normalize your tables. Now that they are tiny. It's going to be harder when they have 400M rows. – ypercubeᵀᴹ May 27 '14 at 20:17
  • But is it really better @ypercube? is it faster than csv? – Yekhezkel Yovel May 27 '14 at 22:15
3

It may or may not be faster, depending on your data distribution and the queries you execute. What it will be is better.

Normalisation isn't a goal in itself. It's a series of processes one applies to remove potential errors while changing data. The output is a schema which is resilient to changing data. Without normalisation you leave yourself open to inconsistent data. It really doesn't matter how fast your site runs; if it's wrong it's wrong and it's no less wrong by being wrong quickly.

Separated values could potentially be faster if your current queries retrieve too much information because it is all bundled up together in CSV columns. It will definitely be faster if, down the line, you discover you have to join to another table on one value currently embedded in a CSV. At that point your performance will fall off a cliff.

0

No, your db weren't probably faster because of multiple causes:

  • 400 record is much fewer which were needed for optimization on the table structure. Probable your whole db will be in the ram (block cache), thus it will be enough fast even if only linear queries will be run.
  • Multiple tables are needed mostly if there is a need for optimization or consistence. In your place it is clearly not the situation.

On the long-term I suggest a little bit of digging into SQL, table structures, normalization and normal forms, first because it gives very good results, second because it is probably unavoidable on the todays IT industry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.