Answer the question
In order to leave comments, you need to log in
What is the best way to store a lot of text in a table?
MariaDB, InnoDB
The table will have 200 text fields and one numeric (int) id.
Quite frequent select by id with only one specific text field being selected. And rare insert with one cron script. And no update and delete.
Is this table architecture reasonable? Wouldn't it be better to transfer the texts to 200 text files and read/write them via fseek((id - 1) * N), where N is the maximum possible text length?
Answer the question
In order to leave comments, you need to log in
As your heart desires
In mysql, large fields ( BLOB, TEXT *) are stored separately from the table, in the table itself there is only a pointer.
For example, take a look at Habr has a post that has large text fields.
And every second someone requests a specific post with this text and there is nothing, everything is fine.
The question of how to store should be answered only after you have answered the question of how you want to read it. Do you need to filter by these fields or search, for example, etc.
Depending on this answer, there will be recommendations. mysql with texts works without problems, there are search tools, etc. Keep everything there as it is and do not invent problems for yourself.
ps foreshadowing the question, if the texts are, for example, heavy books (for example, the librusec database), then storing files in the database itself is pointless and even harmful. Those. if you do not need to parse the contents of the text, you basically do not care how to store, but databases can give an additional (small) overhead in terms of space used and even for reading, compared to ordinary files (the exception is when there are millions of them, problems may arise there due to the selected file system).
Files against databases have one good property - it is more convenient for the administrator to work with them, since backup and database recovery are much harder to do than working with files, but there are more opportunities to shoot yourself in the foot on files ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question