DEV Community

Muhammad Hussain
Muhammad Hussain

Posted on

Ruby on Rails reselect and rewhere lets you optimize performance

Enhance your Rails queries with ActiveRecord's reselect and rewhere methods!

  1. reselect: Streamline your data retrieval by dynamically adjusting the SELECT clause in your queries. Instead of rewriting entire queries, reselect lets you optimize performance by selecting only the necessary columns. Perfect for efficient data fetching and cleaner code!. like Post.where(category:'Technology').reselect(:title, :created_at)
  2. rewhere: Modify existing WHERE clauses on-the-fly without starting from scratch. Whether adapting filter criteria or handling dynamic data conditions, rewhere empowers developers to build adaptable queries for dynamic data filtering and efficient querying. like User.where(active: true).rewhere(last_login_date: Date.today - 7.days)

Top comments (0)