rails datatables pre-generate view/table for raw records -
i have table 1.2 milion of records , count rise. on table need show records related contractor , need find records name or other identifier , data provided 3rd party not correct need use pg_trgm % operator search. set tgrm index on postgres helped , initial query runs 4 seconds acceptable, when want switch next page, every page takes 25seconds.
i use gem
https://github.com/jbox-web/ajax-datatables-rails
so code geting raw records looks this
def get_raw_records activerecord::base.connection.execute("select set_limit(0.80);") contract.where("conico = ? or conname % ?", options[:conico], options[:conname]) end
so thinking if possible somehow pregenerate view raw_records records found , use standard search , pagination on view. view should droped after defined time.
Comments
Post a Comment