No commit activity in last 3 years
No release in over 3 years
Temp Table for activerecord
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17
~> 0.4.1
~> 0.18.4
~> 10.0
~> 3.0
~> 1.3

Runtime

>= 4.2.3
 Project Readme

ActiverecordTemptable

ActiveRecordTemptable provides with_temptable method to cache query results using temporary table.

Installation

Add this line to your application's Gemfile:

gem 'activerecord_temptable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activerecord_temptable

Reasoning

Creating temp tables to save time once querying big result set multiple times(different groupings, count etc) with a complex query.

Usage

ActiveRecordTemptable.with_temptable can be used to cache complex query's result.

For example using scheme from RailsTutorial

ActiveRecordTemptable.with_temptable(current_user.feed, [:user_id]) do |microposts|
  @most_microposts = microposts.group(:user_id).count
  @not_own_microposts = microposts.where.not(user_id: current_user).to_a # note that to_a is needed to load records
end

Development

After checking out the repo, run bin/setup to install dependencies and create databases. Then, run rake spec to run the tests.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/railwaymen/active_record_temptable.

Code Status

Build Status