Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Strip your TEXT fields - Exeter Web Feb/2016

Strip your TEXT fields - Exeter Web Feb/2016

We use a TEXT field to store JSON, plain text and sometimes even HTML content. But why this kind of field is so prejudicial to your database? What can we use instead to have the same flexibility? And if it can't be avoided, what can be the best solution to using it?

Avatar for Gabriela D'Ávila Ferrara

Gabriela D'Ávila Ferrara

February 25, 2016
Tweet

More Decks by Gabriela D'Ávila Ferrara

Other Decks in Programming

Transcript

  1. alter table •creates a temporary table with the new structure

    •copies the data from the old table to the new one •consolidates the new table
  2. alter PK: INT -> BIGINT - 2.147.483.648 TO
 2.147.483.647 INT

    - 922.337.203.854.775.808 TO 922.337.203.854.775.807 BIGINT Illustration out of scale
  3. case • > 750 GB • > 380 million lines

    • 3 TEXT fields • Auto increment: 898.191.090
  4. storage • 1 file in the disk for each row

    for each TEXT field • stored in different location than the table data itself • each field up to 4 MB
  5. MyISAM • fastest read speed • supports FULLTEXT indexes •

    non transactional • less data reliability
  6. InnoDB • transactional • better data integrity • until MySQL

    5.6 it didn’t support FULLTEXT indexes in TEXT fields
  7. querying into TEXT fields • inefficient search with LIKE statement

    • slow DDL operations (like alter table) • unnecessary increase of the table size
  8. conclusion • there is no silver bullet solution • some

    implementations may add an additional layer of complexity to the application • some implementation works better with decoupled applications