Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is get_raw_records called three times? #367

Open
kunzig940 opened this issue Jul 21, 2020 · 4 comments
Open

Why is get_raw_records called three times? #367

kunzig940 opened this issue Jul 21, 2020 · 4 comments

Comments

@kunzig940
Copy link

kunzig940 commented Jul 21, 2020

When debugging, get_raw_records is called three times. How can I bypass such behavior? For example the logs show:

  def get_raw_records
    puts "Raw Records"
    User.all
  end

Logs:

Raw Records
   (0.7ms)  SELECT COUNT(*) FROM "users"
Raw Records
  CACHE  (0.0ms)  SELECT COUNT(*) FROM "users"
Raw Records
  User Load (0.5ms)  SELECT  "users".* FROM "users" ORDER BY users.first_name ASC LIMIT $1 OFFSET $2  [["LIMIT", 75], ["OFFSET", 0]]

If I return zero User records (i.e. User.none) it is only called twice so I'm assuming it's something to do with sorting/filtering in the background.

@n-rodriguez
Copy link
Member

sorting/filtering in the background.

exactly

See https://github.com/jbox-web/ajax-datatables-rails/blob/master/lib/ajax-datatables-rails/base.rb#L32

@kunzig940
Copy link
Author

kunzig940 commented Jul 22, 2020

Is there a way to bypass the additional calls cleanly by any chance? I have the data exactly how I need it on the first fetch. Thanks for the gem it's kept things a lot cleaner.

The main issue is that I call elasticsearch on AWS in get_raw_records so calling it 3 times slows things down considerably. I'm wondering if get_raw_records should only be the initial models & joins and then the filter_records(records) method should have the logic? Will report back.

@NeimadTL
Copy link

@kunzig940, any update on this please? having the same issue.

@kunzig940
Copy link
Author

Unfortunately I didn't dive further into it. Struggling with the additional_data mechanism currently!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants