27
strip your `TEXT` fields Gabi @gabidavila http://gabriela.io

Strip your TEXT fields - Exeter Web Feb/2016

Embed Size (px)

Citation preview

Page 1: Strip your TEXT fields - Exeter Web Feb/2016

strip your `TEXT` fields

Gabi@gabidavila

http://gabriela.io

Page 2: Strip your TEXT fields - Exeter Web Feb/2016

about• Data Engineer• @Crowdcube

Page 3: Strip your TEXT fields - Exeter Web Feb/2016

uses• serialised Arrays• JSON• large strings• images*

Page 4: Strip your TEXT fields - Exeter Web Feb/2016
Page 5: Strip your TEXT fields - Exeter Web Feb/2016

how does it work?

Page 6: Strip your TEXT fields - Exeter Web Feb/2016

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

Page 7: Strip your TEXT fields - Exeter Web Feb/2016

example

Page 8: Strip your TEXT fields - Exeter Web Feb/2016

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

BIGINTIllus

trat

ion

out o

f sca

le

Page 9: Strip your TEXT fields - Exeter Web Feb/2016

case• > 750 GB• > 380 million lines• 3 TEXT fields• Auto increment: 898.191.090

Page 10: Strip your TEXT fields - Exeter Web Feb/2016

how long did it take?

Page 11: Strip your TEXT fields - Exeter Web Feb/2016

2 days

Page 12: Strip your TEXT fields - Exeter Web Feb/2016

why?

Page 13: Strip your TEXT fields - Exeter Web Feb/2016

speed

fast slow

Page 14: Strip your TEXT fields - Exeter Web Feb/2016

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

Page 15: Strip your TEXT fields - Exeter Web Feb/2016

engines

Page 16: Strip your TEXT fields - Exeter Web Feb/2016

MyISAM• fastest read speed• supports FULLTEXT indexes• non transactional• less data reliability

Page 17: Strip your TEXT fields - Exeter Web Feb/2016

InnoDB• transactional• better data integrity• until MySQL 5.6 it didn’t support FULLTEXT

indexes in TEXT fields

Page 18: Strip your TEXT fields - Exeter Web Feb/2016

querying into TEXT fields

• inefficient search with LIKE statement• slow DDL operations (like alter table)• unnecessary increase of the table size

Page 19: Strip your TEXT fields - Exeter Web Feb/2016

possible alternatives

Page 20: Strip your TEXT fields - Exeter Web Feb/2016

fastest search

Page 21: Strip your TEXT fields - Exeter Web Feb/2016

search servers• indexes large bodies• api bindings• decoupled

Page 22: Strip your TEXT fields - Exeter Web Feb/2016

smart retrieval

Page 23: Strip your TEXT fields - Exeter Web Feb/2016

content delivery network

• high availability• cheap

Page 24: Strip your TEXT fields - Exeter Web Feb/2016

TEXT field within the RDBMS

Page 25: Strip your TEXT fields - Exeter Web Feb/2016
Page 26: Strip your TEXT fields - Exeter Web Feb/2016

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

Page 27: Strip your TEXT fields - Exeter Web Feb/2016

thanks!come say hi :)