Considered “The world's most advanced open-source database” • Successfully used by thousand of companies around the world • SQL follows SQL standard from ISO
'twitter'").first => #<Blog id: 1, ... # Returns all objects where the key ‘twitter’ has the value ‘twitter.com/thiagopradi’ > Blog.where("contact_infos -> 'twitter' = 'twitter.com/thiagopradi'").first => #<Blog id: 1, ...
slow • Full Text Search for the rescue! • Support out of box! No extra dependencies (Sphinx/Lucene) • Integrated to ActiveRecord with the gem texticles, by @tenderlove
to_tsquery('english', 'Sample')) AS "rank0.8922075761585498" # FROM "posts" WHERE (to_tsvector('english', "title") # @@ to_tsquery('english', 'Sample')) ORDER BY "rank0.8922075761585498" DESC
conditions • Useful in different situations, from ensure uniqueness between rows or building indexes on the most active data • Integrated with Rails (Rails 4)
= User.where('auth_token = ?', params[:auth_token]).first if @user.present? @product = @user.products.create(params[:product]) respond_with(@product) else head :bad_request end end end
Processing by ProductsController#create as XML Parameters: {"auth_token"=>0, "product"=>{}} User Load (3.9ms) SELECT "users".* FROM "users" WHERE (auth_token = 0) ORDER BY "users"."id" ASC LIMIT 1 PG::Error: ERROR: operator does not exist: character varying = integer LINE 1: SELECT "users".* FROM "users" WHERE (auth_token = 0) ORDE...
Processing by ProductsController#create as XML Parameters: {"auth_token"=>0, "product"=>{}} User Load (0.8ms) SELECT `users`.* FROM `users` WHERE (auth_token = 0) ORDER BY `users`.`id` ASC LIMIT 1 (0.3ms) BEGIN SQL (2.9ms) INSERT INTO `products` (`created_at`, `updated_at`, `user_id`) VALUES ('2013-03-08 05:40:11', '2013-03-08 05:40:11', 1) (0.7ms) COMMIT
the hood • Some locks / constraints can make your asynchronous application behave like serial processing. • Study about MVCC - Multi-Version Concurrency Control