Monday, 22 February 2016

Codes for less memory usage and fast interacting with database :

pluck:  User.pluck(:id, :name, :email)

Postgres cursor:  https://github.com/afair/postgresql_cursor (gem-It will be use only with postgres db)

Select with where condition:
Client.select(:id, :name).map { |c| [c.id, c.name] }
Client.select(:id, :name).where(name: "hemant")
http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations

minimun, maximum, includes, select, pluck, sum, explain



User.where(id: 1).includes(:articles).explain

No comments:

Post a Comment