What is the difference TEXT and LONGTEXT?

6

I'm working on a system where I'm going to import data from an Excel. Since these data will be temporary, I want to save the information for this imported column in JSON format in the database.

So, I was in doubt about using TEXT or LONGTEXT .

Of course this case is just an example, but there are other cases where the doubt comes in mind, for example, when saving a publication of a blog system in the bank. I would have to use TEXT or LONGTEXT ?

I imagine it makes a difference just because of the names, not because of technical details of the difference between them.

So my question is:

  • What is the difference between LONGTEXT and TEXT ?

  • Would using LONGTEXT make my bank use more features than using TEXT ?

  • Is there a difference in read speed or performance when choosing one or the other?

  • In what cases would I have to use LONGTEXT instead of TEXT ?

NOTE : Actually, I do not even want someone to point out what I should do with these data I'm importing, but I'd just like to know the difference between two types (LONGTEXT and TEXT). Even though I know the new version of MYSQL has the format JSON , but that's another story, since I do not use the new version of MYSQL *.

    
asked by anonymous 07.02.2017 / 12:06

1 answer

7

At Documentation you will find a lot about each type, summarizing in Sizes:

      Tipo | Tamanho Máximo
-----------+--------------------------------------
  TINYTEXT |           255 (2^ 8−1) bytes         
      TEXT |        65,535 (2^16−1) bytes = 64 KiB
MEDIUMTEXT |    16,777,215 (2^24−1) bytes = 16 MiB
  LONGTEXT | 4,294,967,295 (2^32−1) bytes =  4 GiB
  • What's the difference between LONGTEXT and TEXT? Maximum Memory Allocation (size) as the Table above;

  • Using LONGTEXT would my bank use more features than using TEXT? Exactly, for each line in your Bank it would be necessary to reserve, clear, validate more memory.

  • Is there a difference in read speed or performance when choosing one or the other? Performance differences are few in small Bases (you're hardly concerned with base performance with tens or few hundred results), but they can be very palpable for large (1TB +), so the answer is yes. >
  • In which cases would I have to use LONGTEXT instead of TEXT? When storing more than 16Mi Chars. Store a whole book, or all information from a RAW image, for example.
07.02.2017 / 12:09