Does the database store a comma-separated list in the database that consumes a lot of memory space?

We are working on a project that has some product attribute design. I don’t think that keeping attributes separated by commas would be good practice. But my friend told me that a comma-separated list would save space.

I read an article in stackoverlow Does a delimited list in a database column really keep that bad?

But no one mentioned the memory problem, they all praised for keeping individual records. Can anyone tell me a real story?

+4
source share
3 answers

The answer to the answer in a related question covers the questions pretty well. There are few, if any, real advantages to storing data in such an abnormal way. Using multiple-valued fields will cost you in the long run, and possibly in the short term.

If you are 100% sure that your application will NEVER need to process (filter, organize, group, etc.) the contents of your serialized data (a comma-separated list), then this will not affect your application. In most cases, when people make this assumption, they “burn their fingers”, because the requirements for the application change over time.

Processing multi-valued fields will require more memory and more CPU cycles due to a full scan of the table required for anything other than just reading the contents of the field. Googling for "mysql multivalued field performance issues" returns a lot of results.

+2
source

There is no reason to justify space. The size of the data may actually be smaller by normalization, since you will not need to put extra characters in the data (commas or whatever you use to separate).

Your friend is probably just afraid of the prospect of writing “complex” queries related to joining tables, and is trying to find an excuse for him (and not succeed).

In addition, enough has already been written about why you normalize the data.

+4
source

Yes, this certainly saves space compared to creating a new table. However, it is not recommended to store data in this way. Regarding the creation of a new table, I do not think that this can greatly affect. You can focus on another area, for example, create the right index in a table, etc.

-1
source

Source: https://habr.com/ru/post/1402823/


All Articles