$30 off During Our Annual Pro Sale. View Details »

Don't Use NoSQL

Don't Use NoSQL

Mathias Meyer

January 12, 2012

More Decks by Mathias Meyer

Other Decks in Technology


  1. Don’t Use NoSQL Mathias Meyer, @roidrage

  2. None
  3. What do we use NoSQL for?

  4. Queues

  5. Resque Delayed Job CouchDB Queue Service Replacing RabbitMQ with MongoDB

  6. “Doesn’t matter what kind of tool it is, at least

    one developer will eventually use it as a queue.” Me, 2012
  7. Analytics

  8. Visitor Tracking Split Testing API Limiting Logging

  9. Schemaless

  10. Documents

  11. Caching, Sessions

  12. “Doesn’t matter what kind of database it is, at least

    one developer will eventually use it as a cache.” Me, 2012-01-11
  13. Why?

  14. We can?

  15. We wants it?

  16. We don’t know better?

  17. Cause and Effect

  18. We abuse the database as a queue

  19. We hit memory limits hard

  20. Transactions

  21. Joins

  22. Schemas

  23. There’s always a schema.

  24. We pay for our choices.

  25. What to do instead?

  26. Use the right tool for the job?

  27. How do we know the right tool?

  28. RabbitMQ, Kestrel, Gearman for queues

  29. Graphite for statistics

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

  31. PostgreSQL Arrays for queues?

  32. PostgreSQL Arrays for queues? for lists

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

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

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

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

  37. Build your own tools.

  38. Learn a new tool every month.

  39. Don’t Use NoSQL

  40. Unless you really have to.

  41. Thoughts?

  42. Examples

  43. 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';
  44. PostgreSQL XML create table herukai (id serial primary key, data

    xml); insert into herukai (data) values ('<herukai><name>Dylan Egan</name><tags><tag>heroku</tag></tags></ herukai>'); select xpath('//herukai/name/text()', data) from herukai; SELECT * from herukai where (xpath('//herukai/name/text()', data)) [1]::text = 'Dylan Egan'::text;
  45. 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'];
  46. pt-online-schema-change pt-online-schema-change h=127.1,t=users --alter “ADD COLUMN twitter_name varchar(40)” --drop-old-table