Slide 1

Slide 1 text

Don’t Use NoSQL Mathias Meyer, @roidrage

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

What do we use NoSQL for?

Slide 4

Slide 4 text

Queues

Slide 5

Slide 5 text

Resque Delayed Job CouchDB Queue Service Replacing RabbitMQ with MongoDB

Slide 6

Slide 6 text

“Doesn’t matter what kind of tool it is, at least one developer will eventually use it as a queue.” Me, 2012

Slide 7

Slide 7 text

Analytics

Slide 8

Slide 8 text

Visitor Tracking Split Testing API Limiting Logging

Slide 9

Slide 9 text

Schemaless

Slide 10

Slide 10 text

Documents

Slide 11

Slide 11 text

Caching, Sessions

Slide 12

Slide 12 text

“Doesn’t matter what kind of database it is, at least one developer will eventually use it as a cache.” Me, 2012-01-11

Slide 13

Slide 13 text

Why?

Slide 14

Slide 14 text

We can?

Slide 15

Slide 15 text

We wants it?

Slide 16

Slide 16 text

We don’t know better?

Slide 17

Slide 17 text

Cause and Effect

Slide 18

Slide 18 text

We abuse the database as a queue

Slide 19

Slide 19 text

We hit memory limits hard

Slide 20

Slide 20 text

Transactions

Slide 21

Slide 21 text

Joins

Slide 22

Slide 22 text

Schemas

Slide 23

Slide 23 text

There’s always a schema.

Slide 24

Slide 24 text

We pay for our choices.

Slide 25

Slide 25 text

What to do instead?

Slide 26

Slide 26 text

Use the right tool for the job?

Slide 27

Slide 27 text

How do we know the right tool?

Slide 28

Slide 28 text

RabbitMQ, Kestrel, Gearman for queues

Slide 29

Slide 29 text

Graphite for statistics

Slide 30

Slide 30 text

pt-online-schema-change for schema updates http://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html

Slide 31

Slide 31 text

PostgreSQL Arrays for queues?

Slide 32

Slide 32 text

PostgreSQL Arrays for queues? for lists

Slide 33

Slide 33 text

MySQL 5.6 Memcached API http://blogs.innodb.com/wp/2011/04/nosql-to-innodb-with-memcached/

Slide 34

Slide 34 text

HandlerSocket for MySQL http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html

Slide 35

Slide 35 text

PostgreSQL hstore for documents http://blog.creapptives.com/post/14062057061/

Slide 36

Slide 36 text

PostgreSQL XML for documents http://robots.thoughtbot.com/post/13829210385/

Slide 37

Slide 37 text

Build your own tools.

Slide 38

Slide 38 text

Learn a new tool every month.

Slide 39

Slide 39 text

Don’t Use NoSQL

Slide 40

Slide 40 text

Unless you really have to.

Slide 41

Slide 41 text

Thoughts?

Slide 42

Slide 42 text

Examples

Slide 43

Slide 43 text

PostgreSQL hstore create table herokaih (id serial primary key, attr hstore); create index attr_idx on herokaih using gist (attr); insert into herokaih (attr) values (hstore(ARRAY['name', 'Dylan Egan'])); select attr -> 'language' from herokaih where attr @>'name=>Dylan';

Slide 44

Slide 44 text

PostgreSQL XML create table herukai (id serial primary key, data xml); insert into herukai (data) values ('Dylan Eganheroku herukai>'); select xpath('//herukai/name/text()', data) from herukai; SELECT * from herukai where (xpath('//herukai/name/text()', data)) [1]::text = 'Dylan Egan'::text;

Slide 45

Slide 45 text

PostgreSQL Arrays create table herokail (id serial primary key, tags text[], name varchar(200)); insert into herokail (name, tags) values ('Dylan Egan', ARRAY['meat']); update herokail set tags = array_append(tags, 'beer') where name = 'Dylan Egan'; select name from herokail where tags @> ARRAY['beer'];

Slide 46

Slide 46 text

pt-online-schema-change pt-online-schema-change h=127.1,t=users --alter “ADD COLUMN twitter_name varchar(40)” --drop-old-table