Skip to content

Instantly share code, notes, and snippets.

@sononum
Created August 8, 2013 09:26
Show Gist options
  • Save sononum/6183139 to your computer and use it in GitHub Desktop.
Save sononum/6183139 to your computer and use it in GitHub Desktop.
accelerate Kaminari with Postgres insert into config/initializers/kaminari.rb
module Kaminari
module PageScopeMethods
def total_count
@_hacked_total_count || (@_hacked_total_count = self.connection.execute("SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname ='#{table_name}'").first["reltuples"].to_i)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment