jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
586 stars 228 forks source link

Allow overriding filter_records, sort_records #272

Closed ohaddahan closed 6 years ago

ohaddahan commented 6 years ago

I stumbled upon some performance issues that aren't originating from the Gem but affect the performance.

  1. The default behaviour includes two calls to count , before and after filtering. This can be expensive on large tables , I recommend as a minimum to explain in the documentation that get_raw_records should include some where query to minmize full table sweeps.

  2. It seems PostgreSQL and rails order don't act as expected (at least by me). Might be related to the query planning in the Gem. It seems to run ORDER BY on the entire table and SELECT after. While the other way around seems a lot more efficient , assuming the SELECT will minimize the number of results dramatically.

  3. Continuing (2) , I tried overriding filter_records and sort_records right under where it says

# ==== These methods represent the basic operations to perform on records

to try and play with the query planning but they don't seem to be called from the

ohaddahan commented 6 years ago
  1. I think I read explain wrong , need to solve some DB issues on my application. Looking for some way to timeout specific slow queries.

  2. Need to override

module AjaxDatatablesRails
  module ORM
    module ActiveRecord
      def filter_records(records)
      end
      def sort_records(records)
      end   
    end
  end
end

Just placing them inside the datatable class doesn't seem to help.

n-rodriguez commented 6 years ago

I think I read explain wrong , need to solve some DB issues on my application.

Ok.

Just placing them inside the datatable class doesn't seem to help.

I know : https://github.com/jbox-web/ajax-datatables-rails/issues/228. I'm looking for a solution ;)